What is a multithreading model in OS?


Multithreading is a process divided into a number of smaller tasks. Each task is represented or called it as a “Thread”. That means a thread is a lightweight of process. A number of such threads within a process executes at a time is called “multithreading”.

The operating system’s additional capability is supporting multithreading.

Based on the functionality, threads are divided into four categories and these are given below −

  • One process, one thread.

  • One process, multiple threads.

  • Multiple processes, one thread per process.

  • Multiple processes, multiple threads per process.

Let us see how the above functionality represents in the pictorial form −

  • One process, one thread − It is a traditional approach, in which the process maintains only one thread, so it is called a single threaded approach. For example − MS-DOS OS supports one thread, one process approach.

  • One process, multiple threads − Here, a process is divided into a number of threads. For example − JAVA runtime environment.

  • Multiple processes, one thread per process − An Operating system supports multiple user processes but only supports one thread per process. For example − UNIX operating system.

  • Multiple processes, multiple threads per process − Here, each process is divided into a number of threads. For example − Windows 2000, Solaris LINUX.

Differences

The major differences between process and threads are as follows −

ProcessThread
Process cannot share the same memory area that means it cannot share the address space.Thread can share memory and files.
It takes more time to create a process.It takes less time to create a thread.
It takes more time to complete the execution and more time for termination also.It takes less time to terminate.
Execution is very lowExecution is very fast.
It takes more time to switch between two processesIt takes less time to switch between two threads.
Implementing the communication between processes is a bit more difficult.Communication between two threads is very easy to implement because the thread shares the memory.
System calls are required to communicate with each other.System calls are not required.
Process is loosely coupledThreads are tightly coupled.
It requires more resources to execute.It requires less resources that is why we usually call thread as a light weight process.
Process are not suitable for parallel activitiesSuitable for parallel activity.

Updated on: 30-Nov-2021

1K+ Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements