Multithreading Models
Depending on the support for user and kernel threads, three different multithreading models are :-
1. Many-to-one model
2. One-to-one model
3. Many-to-many model
1. Many-to-one model
· In many-to-one model, many user level threads are mapped to one kernel level thread. (see fig).
· Thread management is done in user space.
· If any of the threads makes a blocking system call, the entire process will be blocked.
· Multiple threads are unable to run in parallel on multiprocessor as only on thread can access the kernel at a time.
· For example Green thread-a thread library of Solaris 2 uses this model.
2. One-to-one model
· In this model, each user thread is mapped to one kernel thread hence the name one-to-one model (see fig.).
· In this model, when one threads makes a blocking system call, the other threads continue to run. Therefore it provides more concurrency than many to-one model.
· It also allows the multiple threads to run on multiprocessors.
· The drawback of this model is that each user thread requires its corresponding kernel thread. Thus the overhead of creating kernel thread burdens the performance of an application.
· The operating systems that implement this model are Windows NT, Window 2000 and OS/2.
3. Many-to-many model
· Many-to-many model multiplexes many user level treads to a smaller or equal number of kernel threads (see fig.)
· The number of kernel threads created depends on a particular application or particular machine.
· Although, this model allows the creation of multiple kernel threads, true concurrency cannot be achieved by this model as the kernel can schedule only one thread at a time.
· In this model, developer can create as many user threads as necessary.
· Also, when a thread performs blocking system call the kernel can schedule another thread for execution.
· This model is supported by Soalris 2 operating system. .
Comparisons between process and threads:-
Sno. | Process | Thread |
1. | Each process has its own distinguish address space in memory. | All threads is a process share the same address space |
2. | Process require more system resources than threads | Threads require less system resourse than process |
3. | Process are independent of one another. | Unlike process, threads are not independent of one another. |
4. | New process takes more time for creation, it also takes its more time to terminate a process | New threads take less time for creation than new process. Moreover threads also take less time to terminate. |
5. | It takes more time to switch between two process. | It takes less time to switch between two threads of a same process. |
6. | Process are more robust in comparison to threads | Threads are less robust. |
No comments:
Post a Comment