[Solved] Preemptive Priority CPU scheduling Algorithm [closed]


As stated in your question, “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”. So, T1 is of more priority than T2, and T2 is of more priority than T3. This means whenever T1 arrives, it will pre-empt other tasks, and T2 will pre-empt task T3.

Among tasks T1, T2 and T3, each of them are composed of an infinite sequence of jobs (or instances) which arrive periodically at intervals of 3, 7 and 20 milliseconds respectively. And, each instance of T1, T2 and T3 requires an execution time of 1, 2 and 4 milliseconds, respectively.

Hence, the corresponding Gantt chart would be:

T1 (0-1), T2 (1-2), T2 (2-3), T1 (3-4), T3 (4-5), T3 (5-6), T1 (6-7), T2 (7-8), T2 (8-9), 
                                                            T1 (9-10), T3 (10-11), T3 (11-12)...
// so first instance of T3 finishes at the end of 12 seconds.

I took that beginning of 1st ms means all the process arrives at time
= 1 and 0 to 1 time is IDLE. and when I take the gantt chart I get answer as 13, whereas answer = 12.

The reason why your answer is not matching is because you have assumed incorrectly.

The question clearly said that “given that all tasks initially arrive at the beginning of the 1st milliseconds…”, which means that the tasks arrived as soon as the timer started, i.e., as soon as the first millisecond started (labelled as 0-1 in my hint in the chart drawn above).

1

solved Preemptive Priority CPU scheduling Algorithm [closed]