Last modified on April 19th, 2020
Threads, Multithreading, Types Models in Operating Systems (OS)
In this tutorial, we will cover the followings;
Threads, Multithreading, Types of thread, Multithreading models in Operating Systems (OS)
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 utilization. It is also called a lightweight process.
Benefits Of threads:
- Threads share common data and do not need to use interprocess communication.
- Threads can take advantage of lightweight.
- There is a higher throughput when multiple threads cooperate in a single job.
Multithreading is an important function of the operating system . Multithreading allows
Operating system to execute simultaneously. Now a day many software is Multithreading. Different applications are treated as a 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 operating system .Allin system modern operating system support kernel-level threading. They allow the kernel to perform multiple tasks and to service multiple kernel system calls simultaneously.
>User Level threads:
User level threads are implemented in user library instead of system calls. The thread switching does not need to call the operating system. It does not cause an interrupt to the kernel. The kernel knows nothing about the user-level thread. The user level threads are very fast.
In M-2-M model much user-level threading is mapped to one kernel thread. It is efficient because it is implemented in userspace. A process using this model will be blocked entirely if a thread makes a blocking system call.only one thread can access the kernel at a time so it cannot run in parallel on a 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 the 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 a multiprocessor system.