MT1 PDF
MT1 PDF
a) Program reads data from input port repeatedly, once before a loop and ten times in this
loop. Each iteration of the outer loop includes an inner delay loop. Program jumps out of the
outer loop if two successive readings are equal. Thus minimum time occurs if first two
readings are equal and maximum time occurs when no two successive readings are equal.
b) In the above mentioned case of minimum execution time, 7 instructions are executed and
thus minimum execution time is 0.7 μs.
2+ 10 x (9+2002)+ 2= 20114 clock cycles, and maximum execution time 𝑡𝑚𝑎𝑥 is 2.0114 ms.
′
𝑡𝑚𝑎𝑥 2.0114
𝑡𝑚𝑎𝑥 = = = 2.0154 𝑚𝑠
1 − 𝑓𝑚𝑎𝑥 𝑡𝑚𝑎𝑥 (𝐼ℎ) 1 − 50𝑥40𝑥10−6
We modify this result noting that a maximum of one interrupt will take place during
execution, thus maximum execution time will be 2.0514 ms.
[2] A hard real-time system runs three tasks using the cyclic executive method. Tasks have
periods of 10 ms, 12 ms, and 15 ms and execution times per period of 2, 2, and 5 ms
respectively. The deadline of each task is equal to its period.
a) If the deadline of each task is equal to its period, find a suitable frame value then construct
an execution schedule for the tasks if possible.
b) If the deadline of third tasks is 10 ms (with period of 15 ms) is the frame value you obtained
in part (a) still suitable? Is it possible to find an execution schedule?
a) Major cycle length will be the lcm of periods, which is 60 ms. Frame length should be
between 5 and 10 (inclusive) and should divide 60, which leaves the values 5, 6, and 10.
The condition 2𝑓 − 𝑔𝑐𝑑 (𝑓, 𝑇𝑖 ) ≤ 𝑑𝑖 for all tasks will be satisfied by f=5 and 6 only. Taking
f=5, we can construct schedule as shown below:
In the above schedule, third task will miss its new deadline only in the second period (starting
at 15, and C ends at 30, missing its deadline at 25). This can be corrected as shown below.
N.B. If we choose f=6, we can construct a schedule in part (a) as shown below
However, in part (b) we cannot modify the schedule as the complete frame for both A and C
in the first period will be the first frame, and they cannot run together in the same frame.
[3] A real-time system is required to run three periodic tasks with periods of 16, 25, and 30
ms, and execution times of 4, 7, and 9.5 ms respectively.
a) Using Liu and Layland theorems, study the schedulability of these tasks using Rate-
Monotonic scheduling, assuming that the deadline of each task is equal to its period.
b) Repeat part (a) for EDF scheduling.
c) Study the schedulability of the tasks using Deadline Monotonic scheduling assuming that
deadlines are 16, 25, and 20 ms respectively (while periods are still as above).
d) Repeat part (c) if pre-emption has an overhead of 0.1 ms.
a) For these tasks, ∑ 𝑢𝑖 = 0.8467 > 3(21⁄3 − 1). Using the critical instant theorem:
As shown in figure, third task will have enough time to finish before its first deadline, thus
tasks are RM schedulable.
c) In this case, priorities will be A then C then B. Using response time analysis:
𝑅𝐴 = 4 < 𝑑𝐴 = 16
𝑅
𝑅𝐶 = 9.5 + ⌈ 𝐶 ⌉ × 4, which converges at 13.5 < 𝑑𝐶 = 20
16
𝑅 𝑅
𝑅𝐵 = 7 + ⌈ 𝐵⌉ × 4 + ⌈ 𝐵⌉ × 9.5, which converges at 24.5 < 𝑑𝐵 = 25
16 30
d) In this case we add 0.2 to the execution times of high priority tasks in the worst case. Then,
for task B:
𝑅 𝑅
𝑅𝐵 = 7 + ⌈ 𝐵⌉ × 4.2 + ⌈ 𝐵⌉ × 9.7, which converges at 25.1 > 𝑑𝐵 = 25
16 30