ITPEC FE Morning April 2021 Question 17

Topic: SoftwareAlso asked in March 2018

In the switching procedure of processes in the multiprogramming shown in the figure below, which of the following is an appropriate combination of OS processing from A to C?

State of process AOS processingState of process BInterruptRunningstateReadystateReadystateRunningstateABC
OptionABC

Explanation

Save, select, restore — the OS first saves the interrupted process's state, then chooses the next process, then restores that process's state.

When the interrupt stops process A, the OS saves its register contents and program counter in A's process control block (A). The scheduler then picks a process from the ready queue (B). Finally the dispatcher loads the chosen process's saved state into the CPU (C), and process B runs from where it left off.

Answer (c)

Why not others:

  • •(a) — restoring first would overwrite A's registers before they are saved, and no process has been selected to restore yet
  • •(b) — the OS cannot restore a running state before it has selected which process's state to restore
  • •(d) — restoring B's state before saving A's would destroy A's register contents, so A could not resume later

Key rule: A context switch always saves the old state first and restores the new one last; the scheduling decision sits between them.

Software · AI-written, may contain errors

This question comes from an official ITPEC past paper. ITPEC Practice is an independent study tool and is not affiliated with ITPEC. See the official FE past-paper collection or Report an issue.