Thread and Thread
Models
The Agenda
1. Threads
2. Multithreading
3. Types of Threads (User/Kernel)
4. Thread Models
Process and Thread
Process and Thread Cont..
Multithreading
Multithreading Cont..
Multithreading Cont..
Thread Types
Thread Types Cont..
User Level Threads
Thread Types Cont..
Kernel Level Threads
Thread Types Cont..
User Level Threads
Thread Types Cont..
User Level Threads
Thread Models
The different multithreading models (types) are given below:
1. One to One Model
2. Many to One Model
3. Many to Many Model
Thread Models cont...
One to One
The one to one model maps each of the user threads to a kernel
thread.
This means that many threads can run in parallel on multiprocessors.
Other user threads can run when one thread makes a blocking
system call.
A disadvantage of the one to one model is that the creation of a user
thread requires a corresponding kernel thread.
Thread Models cont...
(Blocking System Call)
1. A blocking system call is one that must wait until the action can
be completed.
2. If the system call may be lengthy (e.g. involve file IO or
networking IO) this can be a bad thing (e.g. imagine a frustrated
user hammering a "Cancel" button in an application that doesn't
respond because, thread is blocked, waiting for a packet from the
network that isn't arriving).
Thread Models cont...
One to One
Thread Models cont...
Many to One
1. Many to OneMany-to-one model maps many user level
threads to one Kernel-level thread.
2. When thread makes a blocking system call, the entire
process will be blocked.
3. Only one thread can access the Kernel at a time, so
multiple threads are unable to run in parallel on
multiprocessors.
Thread Models cont...
Many to One
Thread Models cont...
Many to Many
The many-to-many model multiplexes any number of user
threads onto an equal or smaller number of kernel threads.
In this model, developers can create as many user threads
as necessary and the corresponding Kernel threads can run
in parallel on a multiprocessor machine.
This model provides the best accuracy on concurrency.
Thread Models cont...
Many to Many
Thread Models cont...
Many to Many