The GATE Grind

GATE 2015 CS – Question 52

Operating System · CPU and I/O Scheduling · 2 marks · Numerical answer

Consider a uniprocessor system executing three tasks $T_1$, $T_2$ and $T_3$, each of which is composed of an infinite sequence of jobs (or instances) which arrive periodically at intervals of 3, 7 and 20 milliseconds, respectively. The priority of each task is the inverse of its period, and the available tasks are scheduled in order of priority, with the highest priority task scheduled first. Each instance of $T_1$, $T_2$ and $T_3$ requires an execution time of 1, 2 and 4 milliseconds, respectively. Given that all tasks initially arrive at the beginning of the 1st millisecond and task preemptions are allowed, the first instance of $T_3$ completes its execution at the end of ________ milliseconds.

Practise this question in The GATE Grind →

Show answer and explanation

Correct answer: 12

Explanation

Priority goes to the shortest period, so $T_1$ is highest, then $T_2$, then $T_3$. Timeline: 0 to 1 $T_1$; 1 to 3 $T_2$; 3 to 4 $T_1$ (new job); 4 to 6 $T_3$ runs for 2 ms; 6 to 7 $T_1$; 7 to 9 $T_2$ (new job); 9 to 10 $T_1$; 10 to 12 $T_3$ runs its last 2 ms. So $T_3$ finishes at 12 ms.