4.4 Threading Issues
Last updated
Was this helpful?
Last updated
Was this helpful?
If one thread in a program calls fork(), does the new process duplicate all threads, or is the new process single-threaded? Some UNIX systems have chosen to have two versions of fork().
One that duplicates all threads and
another that duplicates only the thread that invoked the fork() system call.
The exec() system call typically works in the same way as described in Chapter 3. That is, if a thread invokes the exec() system call, the program specified in the parameter to exec() will replace the entire process—including all threads.
Cancellation
(1) Asynchronous cancellation. One thread immediately terminates the target thread.
(2) Deferred cancellation. The target thread periodically checks whether it should terminate, allowing it an opportunity to terminate itself in an orderly fashion.
Therefore, canceling a thread asynchronously may not free a necessary system-wide resource.
Signal Handling
(1) A signal is generated by the occurrence of a particular event.
(2) A generated signal is delivered to a process.
(3) Once delivered, the signal must be handled.
Lightweight process (LWP)