A lecture note from a university course on operating systems, specifically focusing on threading systems and inter-thread communication. The instructor, trent jaeger, discusses the use of threads in building web servers and web browsers, the differences between thread models, and the implementation of threads in linux and posix. The document also covers inter-thread communication methods such as shared memory and message passing, as well as thread issues like fork/exec and thread cancellation.
An advantage of using kernel threads (e.g., Linux) is that system IPC can be used between threads - Would want optimized paths for common address space
Threading Issues
Thread Cancellation
So, you want to stop a thread from executing
Don’t need it anymore
Remember the browser ‘stop’ example
Two choices
Synchronous cancellation
Wait for the thread to reach a point where cancellation is permitted
No such operation in Pthreads, but can create your own
Asynchronous cancellation
Terminate it now
pthread_cancel (thread_id)
Signal Handling
What’s a signal?
A form of IPC
Send a particular signal to another process
The receiver’s signal handler processes the signal on receipt
Example
Tell the Internet daemon ( inetd ) to reread its config file
Send signal to inetd : kill -SIGHUP
inetd ’s signal handler for the SIGHUP signal re-reads the config file
Note: some signals cannot be handled by the receiving process, so they cause default action (kill the process)
Signal Handling and Threads
So, you send a signal to a process
Which thread should it be delivered to?
Choices
Thread to which the signal applies
Every thread in the process
Certain threads in the process
A specific signal receiving thread
• It depends…
Signal Handling and Threads
Synchronous vs. Asynchronous Cases
Synchronous
Signal is delivered to the same process that caused the signal