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

What a context switch really moves

Computing · Computer Systems · ages 19-20
Name ______________________   Date ____________
  1. A process cannot continue until requested disk data arrives. Which state is it in?

    • Ready
    • Blocked
    • Running
  2. Which description identifies a process?

    • An active program instance with execution state and resources
    • A stored program file with no active execution state or resources
    • A processor core that executes every program without saved state
  3. When awaited disk data arrives, a blocked process must immediately enter the running state.

    Circle one:   True   False

  4. After switching to B, the cache still contains some useful B lines, but B's next required line is absent. What explains that access's extra cost?

    • The absent line must be fetched from a lower memory level
    • Every useful B line must first be erased by the context switch
    • Every open B file must first be copied into the register set
  5. Which order matches the lesson's simplified switch from process A to process B?

    • Resume B, overwrite A's context, then select B's address space
    • Restore B, discard A's unsaved context, then resume B again
    • Save A, select B's address space, restore B, then resume B
  6. A toy kernel performs 3 switches. Each switch performs 16 register copies in total, counting both saving and restoring. How many register copies occur?

    Answer: ______________

  7. A student says every process switch copies all memory bytes and recreates all open files. Which correction fits the lesson?

    • Switching deletes the paused process's memory and file records
    • Switching stores every open file inside the processor registers
    • CPU state changes; memory mappings and open-file records stay stored
  8. The same workload finishes less work per second after switching becomes more frequent. Which mechanism could explain the reduction?

    • Every switch closes all files and destroys all process memory
    • More context handling and possible cache misses consume time
    • Every blocked process immediately becomes ready and runs
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 · It is waiting for an event, not just a CPU, so it is blocked.
  2. An active program instance with execution state and resources · A process is an active program instance, including its execution state and managed resources. It can exist while paused or blocked.
  3. False · The event makes the process ready. It runs only when the scheduler assigns a CPU.
  4. The absent line must be fetched from a lower memory level · The next access misses because its required line is absent. Other useful lines can remain cached.
  5. Save A, select B's address space, restore B, then resume B · Save A's CPU context before replacing it, select B's address space, restore B's saved context and resume B.
  6. 48 · There are 16 total copies per switch and 3 switches: 3 × 16 = 48.
  7. CPU state changes; memory mappings and open-file records stay stored · CPU execution state is saved and restored. Memory mappings and open-file records remain stored. The switch selects the incoming address-space context instead of copying every memory byte or recreating files.
  8. More context handling and possible cache misses consume time · Additional switches can take more time for context handling and scheduling. Cache disruption may add cost, but is not required on every switch.
Worksheet · LightMySky