Chapter 2

PCB and Context Switching

Understand how OS stores process metadata and swaps CPU execution safely.

Estimated time: 18 min

PCB is the process record card; context switch saves one card and loads another.

Without PCB and context switch, multitasking and preemption are impossible.

PCB Fields

From notes

Clear explanation

The Process Control Block tracks identity, CPU state, scheduling attributes, memory pointers, and device/accounting info.

What it really means

It is the OS memory of 'where this process left off' and 'what it owns'.

Example

After an interrupt, CPU registers are saved into the current process PCB before selecting next process.

Key takeaway

PCB is the authoritative process state structure.

Context Switch Steps

From notes

Clear explanation

Interrupt transfers control to kernel, current state is saved, scheduler picks next process, and its state is restored to CPU.

What it really means

Like pausing one game exactly at frame N and resuming another at its saved frame.

Key takeaway

Correct save/restore guarantees process continuity.

  • - Believing context switch does useful user work
  • - Forgetting PCB lives in kernel space
  • - Ignoring overhead impact when quantum is too small
  • - PCB stores PID, state, PC, registers, scheduling and I/O info
  • - Context switch = save current context, load next context
  • - Switching cost is overhead

Exam lens for this topic

What evaluators usually expect in structured exam answers.

Must-use keywords

  • - PID
  • - Program Counter
  • - Registers
  • - Scheduling info
  • - Kernel space

Answer flow

  • - Define PCB as process metadata structure
  • - Draw field-level block diagram
  • - Explain context switch save/restore sequence
  • - Mention overhead nature

Diagram expectations

  • - PCB field block diagram

Repeated pattern: PCB with diagram appears often as direct theory question.

Practice Questions

  • Describe Process Control Block (PCB) with diagram.

    Source: Summer 2023 Q2(B)

    Answer focus: Field list with role of each field.

  • Discuss context switching in OS.

    Source: Winter 2023 Q2(B)

    Answer focus: Sequence, causes, and overhead explanation.

Practice from papers (end-of-topic set)

These paper questions map directly to this topic. Solve now, then compare your structure with linked topics.

Question Bank Linked Here

Open all questions

How to answer linked exam questions

Full question bank