Operating System
Thread and Process Thread

Thread

A thread is a lightweight process and is the basic unit for CPU usage. A process can handle multiple tasks simultaneously by incorporating multiple threads.

  • A thread has its own program counter, register set, and stack.
  • Threads within the same process share resources like the code section, data section, files, and signals.
  • There are two types of threads:
    • User threads (Implemented by users)
    • Kernel threads (Implemented by the operating system)

Process vs Thread

FeatureProcessThread
DefinitionAn independent program with its own resources.A lightweight unit within a process that shares resources.
Memory SpaceEach process has a separate memory space.Threads within the same process share the same memory space.
CommunicationRequires Inter-Process Communication (IPC).Easier communication as threads share the same memory space.
IsolationProcesses are isolated from each other.Threads within the same process are not isolated.
Parallel ExecutionProcesses can execute in parallel.Threads within the same process may execute concurrently, depending on the system and programming model.