Process and Threads in Operating System

Process vs Thread
Process and Threads

A process divided into a number of smaller tasks; each task is called a thread. A number of threads within a process executed at a time is called multithreading in OS. It divided into four categories described further.

Multithreading Models

Multithreading in an operating system divided into four categories.

  1. One Process, One Thread: In this traditional approach, the process maintains only one thread. For example, the MS-DOS operating system supports this approach.
  2. One Process, Multi Threads: In this approach, a process divided into the number of threads. For example, Java Runtime Environment.
  3. Multi Processes, One Thread: Operating system supports multiple user processes but only support one thread process. For example UNIX.
  4. Multi Processes, Multi Threads: In this approach, a process divided into the number of threads. For example Window 2000, Solaris, LINUX.

Difference Between Process and Thread in OS

  • A process cannot share the same memory space whereas; threads can share memory and files.
  • It takes more time to create a process whereas; it takes less time to create a thread.
  • The process takes more time to complete the execution and termination whereas; thread takes less time to terminate.
  • Process execution is slow, but threads execute very fast.
  • Context switching time between two processes is much whereas; context switching time between two threads is less as compared to the process.
  • Implementing the communication between two processes is more difficult, but communication between the two threads is easy to implement because threads share the memory.
  • System calls are required to communicate with each process, but in the case of a thread, system calls not necessary.
  • The loosely coupled process, but tightly coupled threads.
  • The process requires more resources to execute whereas; the thread requires fewer resources to execute. Therefore, the thread is called a lightweight process.
  • A process is not suitable for parallel activity-based whereas threads are suitable for the parallel activity.

Thread Synchronization

All threads within a process share the memory and files. One thread is trying to modify one record in a file it will be affected by other threads. So, it needs to synchronize the activities of threads.

I hope you have cleared about Process and Threads in Operating System.

Practice MCQ Questions of Operating System

Practice Now