Question

Consider a uniprocessor system executing three tasks T1T_1, T2T_2 and T3T_3, each of which is composed of an infinite sequence of jobs (or instances) which arrive periodically at intervals of 33, 77 and 2020 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 T1T_1, T2T_2 and T3T_3 requires an execution time of 11, 22 and 44 milliseconds, respectively. Given that all tasks initially arrive at the beginning of the 1st1^{\text{st}} millisecond and task preemptions are allowed, the first instance of T3T_3 completes its execution at the end of _____ milliseconds.

Official answer and solution
Official answer
12
From
Official GATE 2015 answer key

Solution

Trace rate-monotonic scheduling cycle-by-cycle using static priorities assigned inversely to task periods.

  1. Task parameters and priorities:

    • Task T1T_1: period P1=3 msP_1 = 3\text{ ms}, computation time C1=1 msC_1 = 1\text{ ms}. Priority: Highest.
    • Task T2T_2: period P2=7 msP_2 = 7\text{ ms}, computation time C2=2 msC_2 = 2\text{ ms}. Priority: Medium.
    • Task T3T_3: period P3=20 msP_3 = 20\text{ ms}, computation time C3=4 msC_3 = 4\text{ ms}. Priority: Lowest.
      All three tasks arrive at t=0 mst = 0\text{ ms}.
  2. Execution timeline:

    • Time [0,1][0, 1]: T1T_1 runs for 1 ms1\text{ ms} and completes its first instance. (Remaining: T2T_2 needs 2 ms2\text{ ms}, T3T_3 needs 4 ms4\text{ ms}.)
    • Time [1,3][1, 3]: T2T_2 runs for 2 ms2\text{ ms} and completes its first instance. (Remaining: T3T_3 needs 4 ms4\text{ ms}.)
    • At t=3t = 3: T1T_1 arrives (instance 2). Priority T1>T3T_1 > T_3.
    • Time [3,4][3, 4]: T1T_1 runs for 1 ms1\text{ ms} and completes instance 2.
    • Time [4,6][4, 6]: T3T_3 runs for 2 ms2\text{ ms}. (T3T_3 has 2 ms2\text{ ms} execution remaining.)
    • At t=6t = 6: T1T_1 arrives (instance 3). Preempts T3T_3.
    • Time [6,7][6, 7]: T1T_1 runs for 1 ms1\text{ ms} and completes instance 3.
    • At t=7t = 7: T2T_2 arrives (instance 2). Priority T2>T3T_2 > T_3.
    • Time [7,9][7, 9]: T2T_2 runs for 2 ms2\text{ ms} and completes instance 2.
    • At t=9t = 9: T1T_1 arrives (instance 4). Priority T1>T3T_1 > T_3.
    • Time [9,10][9, 10]: T1T_1 runs for 1 ms1\text{ ms} and completes instance 4.
    • At t=10t = 10: No higher priority tasks are pending. Next arrival is T1T_1 at t=12t = 12.
    • Time [10,12][10, 12]: T3T_3 resumes and executes its remaining 2 ms2\text{ ms}, finishing at t=12 mst = 12\text{ ms}.

Hence, the first instance of T3T_3 completes its execution at the end of 1212 milliseconds.

Final answer

12

Common trap

Forgetting the preemption by T2 at t = 7 ms when tracing the timeline.

The answer is the one in the official GATE answer key. The solution is this site's own explanation.

Source

Paper
GATE 2015 Computer Science and Information Technology (CS) Session 1
Question
56 of 65, printed as CS Q.46
Section
Computer Science and Information Technology

Report an error in this question

GATE questions are the work of the organising institutes. This site is independent and is not affiliated with them.