Multithreading models in Operating System (OS)
Multithreading Models in Operating System
In Operating Systems, where both User Level and kernel level thread exists, there exists a relationship between the two. User Level Thread is mapped to Kernel Level Thread by one of the 3 models –
- Many to One Model
- One to One Model
- Many To Many Model
Many To One Model
- Many User Level Threads are mapped to one Kernel level Thread.
- Does Not support parallel processing of threads in Multicore systems, Because only 1 thread can access kernel at a particular time.
- If 1 thread makes a blocking call, then entire process will stop.
- This is rarely used, mainly cause it does not support Multicore system.
One To One Model
- Each of User thread is mapped to kernel thread.
- Provides more concurrency.
- Whole process does not gets blocked when 1 thread makes a blocking call as other threads can run.
- Creates Overhead as every User thread requires to create the corresponding Kernel Thread for it.
- Supports a particular number of thread only, cause of the overhead caused due to creation of Kernel Level Thread.
- Implemented By Linux and Windows Operating System.
Many to Many Model
- Multiple User Threads are multiplexed to same or less number of Kernel threads.
- This is the best among the three models, as it improves on shortcoming of one to one model and many to one model.
- We can create as number of User Threads as we want, unlike One to One Model.
- There is no issue of process blocking and threads can run parallelly in multiprocess system unlike Many To One Model.
- Banker’s Algorithm
- bankers algorithm for deadlock avoidance in c (in above post itself)Resource Allocation Graph (RAG)
- Dining Philosopher’s Problem
- Bounded Buffer Problem / Producer Consumer Problem
- User Level thread Vs Kernel Level thread
- Multithreading models
- Difference between program and process