written 6.4 years ago by | modified 4.6 years ago by |
Task | T1 | T2 | T3 | T4 |
---|---|---|---|---|
Priority | 4 | 3 | 2 | 1 |
Execution time | 4 | 3 | 4 | 2 |
Start time | 0 | 3 | 5 | 8 |
Deadline | 9 | 8 | 14 | 16 |
written 6.4 years ago by | modified 4.6 years ago by |
Task | T1 | T2 | T3 | T4 |
---|---|---|---|---|
Priority | 4 | 3 | 2 | 1 |
Execution time | 4 | 3 | 4 | 2 |
Start time | 0 | 3 | 5 | 8 |
Deadline | 9 | 8 | 14 | 16 |
written 6.4 years ago by |
Total execution time = 4 + 3 + 4 + 2 = 13.
Total execution time is less than farthest deadline. Therefore, the tasks are schedulable and they can meet the deadline.
Explanation:
i) Initially mark all the start points of all the tasks.
ii) Here, as task T1 has start time 0sec, therefore T1 starts to execute.
iii) At the next start time, i.e. at 3sec task T2 enters and T1 is still executing. Therefore slack times of T1 and T2 at 3 sec are compared.
Slack Time = deadline - time instant - remaining execution time.
(a) At time = 3 sec;
Slack Time of T1 = 9 - 3 - 1= 5 sec
Slack Time of T2 = 8 - 3 - 3 = 2 sec
As slack time of T2 is less than T1, therefore T2 starts executing from time equal to 3sec.
iv) At 5sec task T3 enters and again slack times of T1, T2 and T3 are compared.
(b) At time = 5 sec;
Slack Time of T1 = 9 - 5 - 1 = 3 sec
Slack Time of T2 = 8 - 5 - 1 = 2 sec
Slack Time of T3 = 14 - 5 - 4 = 5 sec
As slack time of T2 is least among others, the execution of T2 continues.
v) At 6sec execution of T2 is completed. Now at 6sec the slack times of T1 and T3 are compared.
(c) At time = 6 sec;
Slack Time of T1 = 9 - 6 - 1 = 2 sec
Slack Time of T3 = 14 - 6 - 4 = 4 sec
As slack time of T1 is less, execution of T1 resumes.
vi) After T1 completes its execution, T3 starts executing as start time of T4 is 8sec.
vii) At 8sec, T4 enters and slack times of T3 and T4 are compared.
(d) At time = 8 sec;
Slack Time of T3= 14 - 8 - 3 = 3 sec
Slack Time of T4 = 16 - 8 - 2 = 6 sec
As slack time of T3 is less than T4, T3 continues its execution and is completed at 11sec.
viii) Task T4 starts after completion of task T3. After 2sec of its execution time, task T4 ends.