Operating System

⌘K
  1. Home
  2. Docs
  3. Operating System
  4. Processes and Threads
  5. Threads, Thread vs Process

Threads, Thread vs Process

A thread is the smallest unit of execution within a process.

• It represents a single path of execution within a process, containing its own program counter, register set, and stack, but sharing the process’s resources such as memory and file descriptors with other threads in the same process.

  • Concurrency: Threads allow a process to perform multiple tasks concurrently, enhancing the application’s performance and responsiveness.
  • Shared Resources: Threads within the same process share the same memory space, which allows for easier communication and data sharing among threads.
  • Lightweight: Compared to processes, threads are lightweight because they do not require separate memory allocation for each thread.
  • User-Level Threads: Managed by a user-level library without kernel support. They are faster to create and manage but lack true parallelism because the kernel does not recognize them.
  • Kernel-Level Threads: Managed directly by the operating system kernel. They support true parallelism and can be scheduled independently by the OS.
  • Hybrid Threads: A combination of user-level and kernel-level threads, aiming to balance performance and functionality.

Threads undergo various states during their execution. The typical states include:

  1. New: The thread is being created.
  2. Runnable: The thread is ready to run and waiting for CPU time.
  3. Running: The thread is currently executing on the CPU.
  4. Waiting: The thread is waiting for another thread to perform a specific action.
  5. Timed Waiting: The thread is waiting for a specified amount of time.
  6. Terminated: The thread has finished its execution.
Thread vs. Process

How can we help?

Leave a Reply

Your email address will not be published. Required fields are marked *