In this tutorial, we will cover the followings;
Threads, Multitreading, Types of thread, Multithreading models in Operating Systems (OS)
Thread in Operating system
Thread is a sequence of instructions within a process.A thread behaves like a process within a process but it does not have its own PCB.A thread is the basic unit of CPU utiliztion.It is also called a lightweight process.
Benefits Of threads:
- Threads share common data and do not need to use inter process communication.
- Threads can take advantage of
- There is a higher throughput when multiple threads cooperate in a single job.
Multithreading is an important function of operating system . Multithreading allows
Operating system to execute simultaneously.Now a day many softwares are Multithreading.Different applications are treated as seprate process with different threads.
Types of Multithreading:
- Kernel Level thread
- User Level thread
> Kernel Level threads:
Kernel level threads are supported within the kernel of the operatin system .Allin system modern operating system support kernel level threading.They allow the kernel to perform multiple tasks and to service multiplre kernel system calls simultaneously.
>User Level threads:
User level threads are implemented in user library instead of system calls. The thread swicthing does not needs to calls operating system.It does not cause interrupt to the kernel.The kernel know nothing about user level thread.The user level threads are very fast .
In M-2-M model many user level threading are mapped to one kernel thtread.It is efficient because it is implemented in user space.A process using this model will be blocked entirely if a thread makes a blocking system call.only one thread can acess the kernel at a time so it cannot run in parallel on multiprocessor.
In one to one modeling each user thread mapped to a kernel thread. It provides a concurrency because it allows another thread to execute if a thread makes a blocking system call. It facilitates parallelism in multiprocessor system.
This Model multiplexes many user level threads to a smaller or equal number of kernel threads.
The number of kernel threads may be specific to either particular machine. The user can create any number of user threads and corresponding kernel threads can run in parallel on multiprocessor system.