Threading Issues
Threading Issues
Following threading issues are:
- The fork() and exec() system call
- Signal handling
- Thread cancelation
- Thread local storage
- Scheduler activation
The fork() and exec() system call
In case if a thread fork is the complete process copied or is the new process single threaded? The answer is here it depends on the system and in case of if new process execs immediately then there is no need to copy all the other thread and if it does not create new process then the whole process should be copied.
Signal Handling
Whenever a multithreaded process receives a signal then to what thread should that signal be conveyed? There are following four main option for signal distribution:
- Signal deliver to the thread to which the signal applies.
- Signal deliver to each and every thread in the process.
- Signal deliver to some of the threads in the process.
- Assign a particular thread to receive all the signals in a process.
Thread Cancellation
Threads that are no-longer required can be cancelled by another thread in one of two techniques:
- Asynchronies cancellation
- Deferred cancellation
Asynchronies Cancellation
It means cancellation of thread immediately. Allocation of resources and inter thread data transfer may be challenging for asynchronies cancellation.
Deferred Cancellation
In this method a flag is sets that indicating the thread should cancel itself when it is feasible. It’s upon the cancelled thread to check this flag intermittently and exit nicely when it sees the set flag.
Thread Local Storage
The benefit of using threads in the first place is that Most data is shared among the threads but, sometimes threads also need thread explicit data. Major libraries of threads are pThreads, Win32 and java which provide support for thread specific which is called as TLS thread local storage.
Scheduler Activation
Numerous implementation of threads provides a virtual processor as an interface b/w user and kernel thread specifically for two tier model. The virtual processor is called as low weight process (LWP). Kernel thread and LWP has one-to-one correspondence. The available numbers of kernel threads can be changed dynamically. The O.S is used to schedule on to the real system.