Thread vs Process

Thread vs Process

Contents
  • Short answer:

    • Thread is a subset of a process
  • Longer answer:

    • Thread is an independent set of values for CPU registers
  • Detailed answer:

    • A thread is an execution context for CPU, which is all the information CPU needs to execute instructions. Essentially:

More about thread

  • Program counter: keeps track of which instruc­tion to execute next
  • Stack: which contains the execution history
  • Registers: which hold its current working variables

A single thread could be displaying the current tab you’re in, and a different thread could be another tab.

  • Short answer:

    • Process is a running program
  • Long answer:

    • The process model is based on two independent concepts: resource grouping and execution (thread)

More about process

  • stack: stores functional calls, local variables
  • heap: memory that is dynamically allocated to a process during its execution
  • text/code: code instructions
  • data: static variables

When you double click on the Google Chrome icon on your computer, you start a process which will run the Google Chrome program

Essentially: Processes are used to group resources together; threads are the entities scheduled for execution on the CPU.

ProcessThread
Process is a running programThread is a subset of a process
Process is heavyweightThread is lightweight
The process is independentThreads share memory
  • Processes have separate address spaces (indepedent)

  • For multiple threads in the same process

    • Threads share same address space and code, data, heap segments
    • Threads DO NOT SHARE STACK
No comment yet.
Powered By Valine
v1.4.14