ITPEC FE Morning October 2020 Question 18
The table below shows the priority of three tasks, A through C, and the operation sequence and the processing time of the CPU and the I/O device when each task is executed independently. Which of the following represents the scheduling condition during the time period of 7 ms after 3 ms have elapsed since A through C became simultaneously ready for execution? Here, there is no I/O contention, and the overhead of the OS is not considered. And the numbers in parentheses indicate processing time, and “waiting” in the answer group indicates that the task is ready and is waiting for the allocation of the CPU.
Explanation
A finishes at 6 ms, B runs 3–4 and 6–7 then starts I/O, C runs 7–9 — trace from 0 ms, letting the higher-priority task take the CPU whenever it becomes ready.
All three tasks are ready at 0 ms, and a task that returns from I/O pre-empts a lower-priority one:
- •0–2: A runs CPU(2); B and C wait
- •2–4: A does I/O(2); B, the highest ready task, runs 2 of its 3 ms of CPU
- •4–6: A is back and pre-empts B, runs CPU(2) and completes at 6; B waits with 1 ms left
- •6–7: B finishes its first CPU burst
- •7–9: B starts I/O(5), until 12; C finally gets the CPU for its CPU(2)
- •9–10: C does I/O(2)
So from 3 to 10 ms: A has I/O 3–4, CPU 4–6, complete; B has CPU 3–4, waiting 4–6, CPU 6–7, I/O 7–10; C waits 3–7, runs CPU 7–9 and has I/O 9–10.
Answer (c)
Why not others:
- •(a) — starts A's first CPU burst at 3 ms after B has used the CPU for 0–3, putting the high-priority A behind the medium-priority B
- •(b) — has B in I/O from 3 ms, so B used the CPU for all of 0–3, yet A still has 1 ms of its first burst left; that needs 4 ms of CPU in 3 ms
- •(d) — first come, first served without priority: B keeps the CPU until 5 and the low-priority C runs 5–7 while A waits from 4 to 7
Key rule: For a scheduling chart that starts part-way, trace from time 0: the state at the window's start depends on everything before it, and with pre-emptive priority a task leaving I/O takes the CPU at once.
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.