Greetings!We have recently published 100+ articles on android tutorials with kotlin and java. If you need, you may visit Android Tutorial for beginners page. You can also check Kotlin Tutorial for beginners. Also, if you are interested in content writing, you can mail us at email@example.com.
In this tutorial, we will learn about multithreading models. We will go through different multithreading models – Many to One model, Many to Many model and One to One model.
Many operating systems provide user level thread and kernel level thread in combined way. The best example of this combined operating system is Solaris. In a combined system, multiple threads within the same application can run in parallel on multiple processors and a blocking system call need not block the entire process.
Multithreading models have three types.
- Many to one model
- One to one model
- Many to Many model
1. Many to One Relationship Multithreading Model
In this relationship, many user threads are mapped to single kernel thread. In this model, if any user thread is blocked due to some reason. The entire process will get blocked. As we have one kernel thread, so, multiple threads are not able to access multiprocessor at the same time.
2. One to One Relationship Multithreading Model
In One to One relationship, each user thread mapped to one kernel thread. For each user thread, corresponding kernel thread will also be created.
This model provides more concurrency than the Many-to-One model. If one thread makes a blocking call, it allows another thread to run.
Disadvantages of One to One Model
- Creating user thread requires corresponding kernel thread. So, One to One increase the load on Operating System.
3. Many to Many Relationship Multithreading Model
In Many to Many relationship, one kernel thread will be associated to many user thread. If one or more user threads makes blocking call, so, other kernel threads will manage the blocking issue and continue executing the task.
Here, many user level threads multiplexed with lesser or equal number of kernel threads. So, one kernel thread may be handling more than one user thread.
Processes can be splitted with multiple processors.