[OS] Program/Process/Thread

Rex Chiang
1 min readDec 28, 2021

Program

  1. The executable file or code that we define in IDE and editor.
  2. Program would not be loaded into the primary memory until it was executed.

Process

  1. Process is an executing instance of a program, and would be loaded into the primary memory.
  2. The OS helps to create, schedule, and terminate the processes which is used by CPU.
  3. Each process are independent, and they would not share the memory.
  4. The other processes created by the main process are called child process.
  5. Inter process communication is slow as processes have different memory address.
  6. Context switching between the process is more expensive, because it involves OS resource.

Thread

  1. Thread is the smallest executable unit of a process.
  2. Threads in the same process share memory of that process.
  3. Inter thread communication is fast as threads in the same process share the same memory address.
  4. Context switching between threads in the same process is less expensive.
  5. If two threads access or change the same resource at the same time, synchronization or deadlock problems may occur.

--

--