ITPEC FE Morning October 2022 Question 18

Topic: Software

In an OS, task scheduling is performed by the priority order method. The table below shows the priorities for three (3) tasks A to C and the execution sequence and execution time of the CPU and I/O device for the tasks when each task is executed individually. What is the idle time of the CPU in milliseconds from the time when the three (3) tasks are set to the ready state to the time when the execution of all of the tasks is finished? Here, there is one (1) CPU, the CPU consists of one (1) core, there is no I/O contention, and no overhead of the OS is considered. In the table below, the numbers in parentheses indicate the execution time for each operation.

TasksPriorityExecution sequence and execution time (in milliseconds) when each task is executed individually
AHighCPU(3) → I/O(5) → CPU(2)
BMediumCPU(2) → I/O(6) → CPU(2)
CLowCPU(1) → I/O(5) → CPU(1)

Explanation

3 ms — build the timeline, giving the CPU to the highest-priority ready task while the others do I/O in parallel.

Time (ms)CPUI/O in progress
0–3Anone
3–5BA (3–8)
5–6CA, B (5–11)
6–8idleA, B, C (6–11)
8–10A, then A endsB, C
10–11idleB, C
11–13B, then B endsnone
13–14C, then C endsnone

Idle time: 2 + 1 = 3 ms. Check: the tasks end at 14 ms and use 5 + 4 + 2 = 11 ms of CPU, so 14 − 11 = 3 ms is idle.

Answer (b)

Why not others:

  • •(a) 2 — counts only the gap from 6 to 8 and misses the one from 10 to 11
  • •(d) 5 — counts all of 6 to 11 as idle, overlooking that A returns from I/O at 8 and runs until 10
  • •(c) 4 — would need the tasks to finish at 15 ms; with 11 ms of CPU work they end at 14

Key rule: CPU idle time = time the last task ends − total CPU time of all tasks; build the timeline to find the end, tracking when each I/O finishes.

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.