Process and Thread Management

A process is a program in execution with its own address space, tracked by a process control block; threads are lighter units that share the process’s memory but keep private stacks, and switching between them costs a context switch.

Key formulas & points

Skim these first — then read the full notes below.

  • Process states: new, ready, running, waiting, terminated
  • Preemptive versus non-preemptive scheduling
  • Multithreading improves I/O-bound concurrency

Topic details

Introduction

This Galvin topic covers how the OS manages execution. You learn the process state model, the contents and role of the PCB, the mechanics and cost of context switching, and the distinction between processes and threads including when multithreading helps.

Key relations & formulas

Formulas (Indian textbook notation)

  • PCBholdsPID,state,registers,memorymapandopenfilesPCB holds PID, state, registers, memory map and open files

Formulas (Indian textbook notation)

  • contextswitch=saverestoreregisterspluspossibleTLBflushcontext switch = \frac{save}{restore} registers plus possible TLB flush

Formulas (Indian textbook notation)

  • athreadsharescodedata/heapbuthasitsownstackandregistersa thread shares \frac{code}{data}/heap but has its own stack and registers

Notation and sign conventions

Relation 1 —
PCBholdsPID,state,registers,memorymapandopenfilesPCB holds PID, state, registers, memory map and open files

Formulas (Indian textbook notation)

  • PCBholdsPID,state,registers,memorymapandopenfilesPCB holds PID, state, registers, memory map and open files
Write this relation with symbols exactly as in Operating System Concepts — Silberschatz, Galvin & Gagne before substituting numbers. Examiners award partial marks for a correct setup even when arithmetic slips.
Relation 2 —
contextswitch=saverestoreregisterspluspossibleTLBflushcontext switch = \frac{save}{restore} registers plus possible TLB flush

Formulas (Indian textbook notation)

  • contextswitch=saverestoreregisterspluspossibleTLBflushcontext switch = \frac{save}{restore} registers plus possible TLB flush
Write this relation with symbols exactly as in Operating System Concepts — Silberschatz, Galvin & Gagne before substituting numbers. Examiners award partial marks for a correct setup even when arithmetic slips.
Relation 3 —
athreadsharescodedata/heapbuthasitsownstackandregistersa thread shares \frac{code}{data}/heap but has its own stack and registers

Formulas (Indian textbook notation)

  • athreadsharescodedata/heapbuthasitsownstackandregistersa thread shares \frac{code}{data}/heap but has its own stack and registers
Write this relation with symbols exactly as in Operating System Concepts — Silberschatz, Galvin & Gagne before substituting numbers. Examiners award partial marks for a correct setup even when arithmetic slips.

Concept in depth

A process bundles a running program with its resources — address space, open files, registers — captured in the process control block so the OS can suspend and resume it. Processes move through states (ready, running, waiting) as they compete for the CPU and block on I/O. Threads exist to reduce this overhead: they share the owning process’s code, data and heap, so switching between threads of one process is cheaper than switching processes (no address-space change), and multiple threads can overlap I/O waits with computation. A context switch saves one execution’s registers and restores another’s, pure overhead that the scheduler tries to minimise.

Assumptions and validity limits

State assumptions explicitly before using any relation for process and thread management — steady state, uniform properties, linear elastic material, ideal gas, incompressible flow, etc., as applicable.
Wrong assumptions invalidate the entire solution even when the formula is correct. In Operating Systems viva and GATE descriptive questions, listing valid assumptions often earns separate marks.

Step-by-step problem approach

1. Read the question and list given data with SI units (common in Operating Systems papers).
2. Draw a neat labelled diagram where applicable — examiners in Indian universities award diagram marks even when arithmetic slips.
3. Identify which relation from this topic applies to process and thread management.
4. Use equation 1:
PCBholdsPID,state,registers,memorymapandopenfilesPCB holds PID, state, registers, memory map and open files
.
5. Use equation 2:
contextswitch=saverestoreregisterspluspossibleTLBflushcontext switch = \frac{save}{restore} registers plus possible TLB flush
.
6. Substitute values, compute, and verify units and sign (direction).
7. State conclusion in one line — e.g. safe/unsafe, stable/unstable, feasible/infeasible.

Applications & exam relevance

Process and Thread Management appears in systems software and backend. In Indian it software curricula this topic is tested because it connects theory to process, memory, and file management.
GATE and semester exams often combine process and thread management with earlier units — revise prerequisites before attempting mixed problems.
Industry interview panels sometimes ask: "Where did you use process and thread management?" — answer with a lab, mini-project, or plant visit example if possible.

Common mistakes in exams

Students think threads have separate address spaces (they share the process’s memory except the stack), forget that a context switch is overhead with no useful work, and confuse the ready state (waiting for CPU) with the waiting state (blocked on I/O). Assuming more threads always means more speed ignores contention.

Quick revision checklist

Before attempting process and thread management problems, confirm you can:
1. Process states: new, ready, running, waiting, terminated
2. Preemptive versus non-preemptive scheduling
3. Multithreading improves I/O-bound concurrency
Revise the solved examples in Operating System Concepts — Silberschatz, Galvin & Gagne and one previous-year GATE or university paper for this unit.

Worked examples

Try the problem first — open the solution when you are ready to check.

Threads versus processes

Problem

Why is switching between two threads of the same process cheaper than switching between two processes?

Solution

Threads of one process share the same address space, so the switch skips changing the memory map and flushing the TLB — only registers and the stack pointer change, unlike a full process switch.

Conceptual check — Process and Thread Management

Problem

In a Operating Systems semester or GATE paper you are asked: "State the main assumption, the governing relation, and one practical consequence of process and thread management." What should a complete answer include?

Exams & GATE

Draw the process state diagram with the ready queue and I/O wait.

📖 Standard books (India)

  • Operating System ConceptsSilberschatz, Galvin & Gagne

    Read: Syllabus unit

    Processes, memory, and file systems