Exercise3 Solution
Exercise3 Solution
Aperiodic Scheduling
J1 J2 J3 J4
Ci 3 6 2 4
Di 8 15 3 11
EDD (Earliest Deadline Due) is a scheduling algorithm that minimizes the maximum lateness. The
Jackson’s rule says that given a set of n independent tasks, any algorithm that executes the tasks in
order of non-decreasing deadlines is optimal with respect to minimizing the maximum lateness.
Assumptions about the task set for applying EDD:
- tasks have same arrival times (synchronous arrivals)
- tasks are independent
EDD is non-preemptive. The EDD produces a feasible schedule given in Figure 1.
5
0
0 2 4 6 8 10 12 14 16 18 20
1
Task 2: Latest Deadline First
Given the precedence graph in Figure 2 and the following table of task execution times and deadlines,
determine a Latest Deadline First (LDF) schedule. Is this schedule feasible?
J1 J2 J3 J4 J5 J6 J7 J8
Ci 3 4 2 3 3 2 2 1
Di 5 8 11 15 12 18 19 20
J5
J1 J2 J4 J6 J7
J3 J8
LDF (Latest Deadline First) is a scheduling algorithm that minimizes the maximum lateness. It assumes
synchronous task activations and is non-preemptive.
The algorithm to produce an LDF schedule proceeds in two stages: firstly, a precedence graph is con-
structed. Going from tail to head: among the tasks without successors or whose successors have been
all selected, LDF selects the tasks with the latest deadline to be scheduled last. At runtime, tasks are
extracted from the head of the queue: the first task inserted in the queue will be executed last.
The queue of tasks scheduled with LDF is as follows: J1 − J2 − J3 − J5 − J4 − J6 − J7 − J8 . The LDF
schedule is presented in Figure 3. On Figure 4 you can find a sketch of how the LDF algorithm proceeds.
2
J5
J5
J1 J2 J4 J6 J8
J1 J2 J4 J6 J8
J3 J7
J3 J7
J5
J5
J1 J2 J4 J6 J8
J1 J2 J4 J6 J8
J3 J7
J3 J7
J5 J5
J1 J2 J4 J6 J8 J1 J2 J4 J6 J8
J3 J7 J3 J7
J5
J1 J2 J4 J6 J8
J3 J7
3
Task 3: Earliest Deadline First
In the following table, five tasks with arrival times, execution times and deadlines are given.
J1 J2 J3 J4 J5
ai 0 2 0 8 13
Ci 3 1 6 2 3
di 16 7 8 11 18
(1) Determine a Earliest Deadline First (EDF) schedule. Is this schedule feasible?
(2) At time t = 3, a new task Jx arrives with execution time Cx = 2 and deadline dx = 10. Can you
guarantee the schedulability of the task set with this new task?
EDF (Earliest Deadline First) is optimal in the sense of feasibility (it minimizes the maximum lateness
under following assumptions: scheduling algorithm is preemptive, the tasks are independent, and may
have arbitrary arrival times). The Horn’s rule says that given a set of n independent tasks with arbitrary
arrival times any algorithm that at any instant executes the task with earliest absolute deadlines among
the ready tasks is optimal with respect to the maximum lateness.
(1) The EDF schedule is feasible, and the respective schedule is shown in the Figure 5.
J5
J4
J3
J2
J1
0 2 4 6 8 10 12 14 16 18 20
(2) The arrival of a new task Jx at time point t = 3 still maintains the schedule feasible. We can
check this by computing ahead the finishing times of the tasks (with respect to the interesting
time points). In the analysis, we consider the tasks in order of increasing deadlines.
We assume an on-line scenario, i.e. in the schedulability test we consider only tasks currently present
in the system. The test is performed every time a new task arrives.
From the schedule in the preceding sub-problem, we know that before task JX arrives at time t = 3
we have:
- tasks J1 , J2 and J3 are feasible
- task J2 finishes before its deadline at t = 3
That is, up to t = 3 all active tasks in the system are feasible.
At t = 3 we have three tasks in the system: J1 , J3 and the new task, Jx . For them we perform
the schedulability test:
4
Task Jx : f2 = f1 + cx (3) = 7 + 2 = 9 ≤ 10 (ok)
Task J1 : f3 = f2 + c1 (3) = 9 + 3 = 12 ≤ 16 (ok)
Thus, at t = 3 all tasks in the system are feasible.
The next task to arrive is J4 . It arrives at t = 8. At t = 8, we have thee active tasks: Jx , J4 and
J1 . The schedulability test at t = 8 proceeds as follows:
Put f0 = t = 8
Task Jx : f1 = f0 + cx (8) = 8 + 1 = 9 ≤ 10 (ok)
Task J4 : f2 = f1 + c4 (8) = 9 + 2 = 11 ≤ 11 (ok)
Task J1 : f3 = f2 + c1 (8) = 11 + 3 = 14 ≤ 16 (ok)
Thus, at t = 8 all tasks in the system are feasible.
Finally, task J5 arrives at t = 13. At t = 13, we have two active tasks: J1 and J5 . The schedulability
test at t = 13 proceeds as follows:
Put f0 = t = 13
Task J1 : f1 = f0 + c1 (13) = 13 + 1 = 14 ≤ 16 (ok)
Task J5 : f2 = f1 + c5 (13) = 14 + 3 = 17 ≤ 18 (ok)
Hence, the whole schedule is feasible. It is given in the figure below:
Jx
J5
J4
J3
J2
J1
0 2 4 6 8 10 12 14 16 18 20
A −→ C, B −→ C, C −→ E, D −→ F, B −→ D, C −→ F, D −→ G
All tasks arrive at time t0 = 0, have a common deadline d = 20 and the following execution times:
A B C D E F G
Ci 3 2 4 3 2 5 1
(1) Construct the precedence graph for this task set. Then, modify the release times and deadlines so
that EDF∗ can be used for its scheduling.
(2) Determine a resulting EDF∗ schedule. For this schedule, compute the average of all response times
of the tasks.
(3) Assume the additional precedence constraint E −→ A. Is there still a feasible schedule for the
above task set? Justify your answer.
5
Solution for Task 4:
EDF∗ schedules tasks with precedence constraints. Release time and deadline of individual tasks are
modified such that all the precedence constraints are satisfied. By doing this, the scheduling problem is
transformed into a problem without precedence constraints, which can then be handled by a "normal"
EDF scheduler.
There are several points to take into consideration while modifying tasks’ release times and deadlines:
Release time modification:
- task must start the execution not earlier than its release time
- task must start the execution not earlier than the minimum finishing time of its predecessors
Deadline modification:
- task must finish within its deadline
- task must finish not later than the maximum start time of its successors
(1) The precedence graph for the given task set is:
A C
B D
6
JG
JF
JE
JD
JC
JB
JA
0 2 4 6 8 10 12 14 16 18 20
Note that for the computation of a task’s response time we consider its original (not modified)
release time. Note also that there are different correct schedules, and the corresponding response
times may be different.
(3) No, the task set is no longer schedulable. Under the new conditions, the constraints among tasks
A, C and E introduce a cycle in the precedence graph. As a result, none of the three tasks can be
executed as first and therefore, no feasible schedule exists.
J1 → J2 , J2 → J3 , J3 → J4 , J5 → J6 , J6 → J7 , J6 → J8 , J2 → J7 , J7 → J4 , J8 → J7 .
J1 J2 J3 J4 J5 J6 J7 J8
ri 0 3 4 0 0 2 0 2
di 3 8 15 15 10 10 10 11
Ci 1 3 3 3 1 1 2 1
J1 J2 J3 J4 J5 J6 J7 J8
ri∗
d∗i
Ci 1 3 3 3 1 1 2 1
(3) Assume that the application is executed on a dual-core platform. At any time t, both cores execute
the two ready tasks (ri∗ ≤ t) with earliest deadlines (Note: A single task cannot be executed on
two cores simultaneously). Using the arrival times and deadlines obtained in (2), construct an EDF
schedule in Figure 8.
7
Core 1
Core 0
0 1 2 3 4 5 6 7 8 9 10 11 12
time
(4) Now assume that the application is executed on a quad-core platform with the same scheduling
rule (4 cores execute the four ready tasks with earliest deadlines). Will executing on the quad-core
platform reduce the completion time of the application? Justify your answer with an explanation.
J1 J5
J2 J6
J8
J3 J7
J4
J1 J2 J3 J4 J5 J6 J7 J8
ri∗ 0 3 6 9 0 2 6 3
d∗i 3 8 12 15 6 7 10 8
Ci 1 3 3 3 1 1 2 1
(3) There are several solutions since the tasks can run either on core 0 or core 1, and one can be seen
in Figure 9. Makespan of all solutions should be 12.
(4) No. J4 cannot be started earlier than time 9. Therefore, the minimum finish time of the application
is 12 (the finish time for the dual core platform).
8
J5 J8 J3 J4 Core 1
J1 J6 J2 J7 Core 0
0 1 2 3 4 5 6 7 8 9 10 11 12
time