0% found this document useful (0 votes)
68 views8 pages

Exercise3 - Solution Introduction For Embedded Systems

The document provides sample solutions to exercises on aperiodic scheduling algorithms, including Earliest Deadline Due (EDD), Latest Deadline First (LDF), Earliest Deadline First (EDF), and EDF* (EDF with precedence constraints). The solutions include determining if a given task set produces a feasible schedule for each algorithm, constructing schedules in Gantt chart form, and analyzing schedulability when new tasks arrive over time or precedence constraints are added. Key steps for each algorithm like constructing precedence graphs and performing schedulability tests are demonstrated.

Uploaded by

quoctrung244
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
68 views8 pages

Exercise3 - Solution Introduction For Embedded Systems

The document provides sample solutions to exercises on aperiodic scheduling algorithms, including Earliest Deadline Due (EDD), Latest Deadline First (LDF), Earliest Deadline First (EDF), and EDF* (EDF with precedence constraints). The solutions include determining if a given task set produces a feasible schedule for each algorithm, constructing schedules in Gantt chart form, and analyzing schedulability when new tasks arrive over time or precedence constraints are added. Key steps for each algorithm like constructing precedence graphs and performing schedulability tests are demonstrated.

Uploaded by

quoctrung244
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 8

Networked Embedded Systems Lab

Prof. Marco Zimmerling

Introduction to Embedded Systems – WS 2022/23


Sample Solution to Exercise 3: Aperiodic Scheduling

Task 1: Earliest Deadline Due

Check whether the Earliest Deadline Due (EDD) algorithm produces a feasible schedule for the following task
set, given that all tasks are synchronous and arrive at time t = 0.
J1 J2 J3 J4
Ci 3 6 2 4
Di 8 15 3 11

Solution to Task 1:

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

Figure 1: EDD schedule.

The tasks are scheduled in the order of non-decreasing deadlines as follows: J3 , J1 , J4 , J2 .

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

Figure 2: Precedence graph.

Solution to Task 2:

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 constructed.
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.

Figure 3: LDF schedule.

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

Figure 4: The LDF algorithm proceeds as depicted (figures left to right)

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?

Solution to Task 3:

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

Figure 5: EDF schedule

(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:
Put f0 = t = 3 (We have absolute deadlines in the problem specification)
Task J3 : f1 = f0 + c3 (3) = 3 + 4 = 7 ≤ 8 (ok)
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.

4
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

Figure 6: EDF schedule (with Jx )

Task 4: Earliest Deadline First – Star

Given are seven tasks A, B, C, D, E, F, G with following precedence constraints:

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.

Solution to 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.

5
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

The modified release times and deadlines are:


A B C D E F G
ri∗ 0 0 3 2 7 7 5

di 11 11 15 15 20 20 20
In particular, the release time modification proceeds as follows:
∗ ∗
for initial nodes {A, B} set rA = rA , rB = rB
∗ ∗ ∗
rC = max{rc , max{rA + CA , rB + CB } = max{0, max{3, 2}} = 3
∗ ∗
rD = max{rD , rB + CB } = max{0, 0 + 2} = 2
rF∗ = max{rF , rC ∗ ∗
+ CC , rD + CD } = max{0, 3 + 4, 2 + 3} = 7
∗ ∗
rE = max{rE , rC + CC } = max 0, 3 + 4 = 7
∗ ∗
rG = max{rG , rD + CD } = max 0, 2 + 3 = 5
The deadline modification proceeds as follows:
for the terminal nodes {E, F, G} set d∗E = d∗F = d∗G = 20
d∗C = min{dC , d∗E − CE , d∗F − CF } = min{20, 20 − 2, 20 − 5} = 15
d∗D = 15
d∗A = 11
d∗B = 11
(2) One resulting EDF∗ schedule, based on the modified release times and deadlines, is presented below.

JG

JF

JE

JD

JC

JB

JA

0 2 4 6 8 10 12 14 16 18 20

Figure 7: EDF∗ schedule

6
The response time of a task is defined as the difference between its finishing time and release time.
Therefore, the average of all response times for the above schedule is computed as follows:
7
1X 5 + 2 + 12 + 8 + 20 + 18 + 13
tr = (fi − ri ) = = 11.14
7 i=1 7

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.

Task 5: Earliest Deadline First – Star

Given are eight aperiodic tasks, J1 to J8 , with their arrival times, deadlines, and execution times as shown in
the table below. Task precedence constraints are as follows:

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

(1) Construct the precedence graph.


(2) Using the EDF∗ algorithm, modify the arrival times and deadlines of the tasks in order to make the tasks
schedulable under EDF. Enter the modified arrival times and deadlines in Table 1.

Table 1: Modified arrival times and deadlines


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.

Core 1

Core 0

0 1 2 3 4 5 6 7 8 9 10 11 12
time

Figure 8: EDF schedule for part (3)

7
(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.

Solution to Task 5:

(1) The precedence graph:

J1 J5

J2 J6

J8

J3 J7

J4

(2) The modified arrival times and deadlines:

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.

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

Figure 9: One solution for part (3)

(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).

You might also like