Processes, Context Switches and What They Cost · seed 1 · A4, ink-friendly. The answer key prints on its own page for grown-ups.

What a context switch really moves

Computing · Computer Systems · ages 19-20
Name ______________________   Date ____________
  1. A process waits for disk data before continuing. Which state is it in?

    • Ready
    • Blocked
    • Running
  2. What is a process?

    • A program while it runs, plus its registers, memory map, and open files
    • Any file stored on disk
    • The processor chip itself
  3. A context switch only copies a few registers and costs nothing else.

    Circle one:   True   False

  4. Right after a switch, the new process runs slowly at first. Why?

    • The cache still holds the old process data
    • Its files were closed by the kernel
    • Its registers were saved wrongly
  5. Order the steps of a context switch.

    • Jump first, then save both states
    • Load next state before saving the old one
    • Save old state, load next state, jump back in
  6. A kernel performs 3 switches. Each switch copies 16 registers directly. How many register copies happen in total?

    Answer: ______________

  7. A student claims the switch cost ends once registers are saved. What is the error?

    • Switches never touch registers
    • Saving registers is unnecessary
    • The claim ignores the cold cache slowdown after the switch
  8. A machine switches ten times more often yet finishes less work. What is the likely cause?

    • Registers got larger
    • Each switch repays the cold cache bill, crowding out real work
    • Blocked processes vanished
LightMySky · lightmysky.comW1-mt_oiOwHKUoXG-s1

Answer key

For grown-ups. Fold this page away before handing over the rest.

What a context switch really moves W1-mt_oiOwHKUoXG-s1

  1. Blocked · Blocked means waiting for an event such as arriving data.
  2. A program while it runs, plus its registers, memory map, and open files · A process pairs running code with everything the kernel tracks for it.
  3. False · Copying is quick, but the new process also inherits a cold cache.
  4. The cache still holds the old process data · Caches fill with whatever ran recently, so the newcomer fetches from slow memory.
  5. Save old state, load next state, jump back in · The kernel stores the paused process before installing the next one.
  6. 48 · Three switches times 16 registers each gives 48 copies.
  7. The claim ignores the cold cache slowdown after the switch · The dear part follows the copy: slow early fetches from a cache of old data.
  8. Each switch repays the cold cache bill, crowding out real work · Frequent switches spend the processor on refetching instead of running programs.
Worksheet · LightMySky