Operating System Threads

<<Previous

Next >>





A Thread is a line of execution.



Process can have a single thread/single line of execution as shown above. However, in most cases, there can be multiple lines of execution in parallel. In such scenarios, OS splits its work into multiple smaller pieces and executes those in different lines of execution.


In this page, we are going to learn about:

  • Advantages and benefits of OS threads
  • Purpose of OS threads
  • What a kernel thread is
  • What an user thread is
  • How the threads use address space
  • How OS threads work on Multi-CPU processors.

What an OS Thread is? What is the purpose of OS threads?


OS Thread is a task executor inside a OS process. Purpose of multiple OS threads inside the same process is to improve CPU utilization. OS Threads came into existence because an OS process can have several activities and there is no need to execute activities in a particular order. A process can split its activities into multiple threads of execution and start those in parallel.




OS Processes use Threads


An OS Thread is uniquely identified by a Thread ID. Each Thread includes:

  • a program counter
  • a stack
  • register set

Each process comprises one or more thread to complete their tasks. These threads can share their code section, data section and other operating system resources like open files and registers with one another.

  • Threads are supposed to be lightweight.
  • It improves the performance of the system by reducing the process overhead.

An OS Process has either a single thread of control or multi-thread control.

  • In case of multithreaded processes, the process can perform more than one task at a time.
  • Nowadays, many of the operating system kernels are multithreaded so that several threads operate in the kernel and each thread can do specific task.

Benefits of using Threads

  • Thread consumes less time to create and manage threads.

  • One thread can share the memory and other resources with another thread which belong to same process. That means, they can share the same address space.

  • More economic to create and to context switch.

  • Increases the responsiveness of the user interactive applications.

  • better utilization of multiprocessor architecture.

  • Use of multithreading on multi-CPU machine increases the concurrency of tasks.


Types of Threads

There are two kind of threads:

  1. User Thread
  2. Kernel Thread

User Thread

      Applications supports and manages the user thread. You can write your own application and split the work done by your application and execute in parallel threads to make your application efficient.

Kernel Thread

      Operating System directly supports and manages the kernel process and kernel threads.

<<Previous

Next >>









Operating System Threads

<<Previous

Next >>





A Thread is a line of execution.



Process can have a single thread/single line of execution as shown above. However, in most cases, there can be multiple lines of execution in parallel. In such scenarios, OS splits its work into multiple smaller pieces and executes those in different lines of execution.


In this page, we are going to learn about:

  • Advantages and benefits of OS threads
  • Purpose of OS threads
  • What a kernel thread is
  • What an user thread is
  • How the threads use address space
  • How OS threads work on Multi-CPU processors.

What an OS Thread is? What is the purpose of OS threads?


OS Thread is a task executor inside a OS process. Purpose of multiple OS threads inside the same process is to improve CPU utilization. OS Threads came into existence because an OS process can have several activities and there is no need to execute activities in a particular order. A process can split its activities into multiple threads of execution and start those in parallel.




OS Processes use Threads


An OS Thread is uniquely identified by a Thread ID. Each Thread includes:

  • a program counter
  • a stack
  • register set

Each process comprises one or more thread to complete their tasks. These threads can share their code section, data section and other operating system resources like open files and registers with one another.

  • Threads are supposed to be lightweight.
  • It improves the performance of the system by reducing the process overhead.

An OS Process has either a single thread of control or multi-thread control.

  • In case of multithreaded processes, the process can perform more than one task at a time.
  • Nowadays, many of the operating system kernels are multithreaded so that several threads operate in the kernel and each thread can do specific task.

Benefits of using Threads

  • Thread consumes less time to create and manage threads.

  • One thread can share the memory and other resources with another thread which belong to same process. That means, they can share the same address space.

  • More economic to create and to context switch.

  • Increases the responsiveness of the user interactive applications.

  • better utilization of multiprocessor architecture.

  • Use of multithreading on multi-CPU machine increases the concurrency of tasks.


Types of Threads

There are two kind of threads:

  1. User Thread
  2. Kernel Thread

User Thread

      Applications supports and manages the user thread. You can write your own application and split the work done by your application and execute in parallel threads to make your application efficient.

Kernel Thread

      Operating System directly supports and manages the kernel process and kernel threads.

<<Previous

Next >>















Learn about Stack Data Structure

Learn about Heap Data Structure

Learn about Operating System

Learn AVL Tree

Learn Djikstra's Algorithm