Process

  • A program is an executable file which contains code that is stored as a file on a disk
  • A program when in execution is a process which reside in RAM
  • Process has a self-contained execution environment
  • Each process has a complete, private set of basic run-time resources
  • Each process has its own memory space
  • To facilitate communication between processes, most operating systems support Inter Process Communication (IPC) resources like:
  • IPC is used not just for communication between processes on the same system, but processes on different systems

Process vs Threads

  • Threads are sometimes called lightweight processes
  • Both processes and threads provide an execution environment, but creating a new thread requires fewer resources than creating a new process
  • Threads exist within a process — every process has at least one
  • Threads share the process’s resources, including memory and open files
  • Threads communicate via Inter-Thread Communication (ITC) while processes communicate via IPC
  • If a process misbehaves then other processes are not affected by it
    • For example chrome tabs, if one tab is unresponsive other tabs work just fine
  • If a thread misbehaves then whole process can go down
ProcessThread
DefinitionProgram in executionLightweight unit of program execution
MemoryOwns own memoryShares memory with other threads
CommunicationInter-Process Communication (IPC)Inter-Thread communication
Context SwitchingMore expensiveLess expensive
Creation overheadMore expensiveLess expensive
ExamplesGoogle Chrome
- Multiple tabs

This helps Google chrome be
responsive even if there is
crash in one of the tabs

There is also Task manager in Google chrome.

Also OS task manager shows
multiple PID for each tab
MS Word (or any word processor)

- Spell/Grammar check
- Autosave
- Rendering UI

Web Browser
- Rendering UI

Process and Thread Scheduling

Thread Scheduling

Memory Model for Threads and Process

Communication model for Threads and Process