ITPEC FE Subject A October 2024 Question 14
A real-time OS that performs preemptive priority scheduling for tasks A and B with A having a higher priority than B. Which of the following is the action that the OS takes?
Explanation
B goes to the ready state and A runs — under preemptive priority scheduling a higher-priority task that becomes runnable takes the CPU at once, and the preempted task stays runnable.
A task is running (holds the CPU), ready (runnable, waiting only for the CPU) or waiting (blocked until an event such as I/O completion). When higher-priority A is launched while B runs, the OS preempts B. B has lost the CPU but waits for nothing else, so it joins the ready queue and resumes when A finishes or blocks.
Answer (a)
Why not others:
- •(b) — the waiting state is for a task blocked on an event; a preempted task is still runnable, so it goes to ready
- •(c) and (d) — launching lower-priority B never preempts higher-priority A; B simply enters the ready queue while A keeps running
Key rule: Preemption moves a task from running to ready; only waiting for an event moves it from running to waiting, and the event's completion moves it from waiting to ready.
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.