4th Chapter: Threading
- What is it?
Basic unit used by CPU
- Composition
Thread ID, program counter, register collection, stack
Multithreading Benefits
- High degree of responsiveness
- Resource sharing
- Economic
- Utilization of multi-processor architectures
Multithreaded models provide methods that are supported by threads:
- User thread
- Kernel threads
Three types of models
Model |
Concept |
features |
Many-to-one |
Mapping many user threads to a kernel thread |
A thread is blocked, the process is blocked, and cannot be run concurrently on multiple processors |
One |
Map each user thread to a kernel thread |
One thread is blocked, another thread can run, can run concurrently on multiple processors, and resource overhead is high |
Many-to-many |
Multiplexing to the same number or fewer kernel threads |
Combine the advantages of both |
Cancellation of the thread
- Asynchronous cancellation: A thread terminates immediately
- Deferred cancellation: Allows threads to terminate in an orderly manner
Cancel Point
Signal Processing mode:
- The signal is generated by the occurrence of a particular event.
- The resulting signal to be sent to the process
- Once sent, the signal must be processed
Question:
- Describe the actions taken by the line libraries in the process of user-level process context switching?
- What parts of the following programs are shared by threads in multithreaded programs? A. Deposit Value B. Heap memory c. global variable D. Stack memory
A threaded thread is shared with heap memory and global variables, but each thread has its own value for storage and stack memory
Operating System notes: Threads