Realtime Task Scheduling 2
Realtime Task Scheduling 2
Realtime Task Scheduling 2
6 30
Embedded System Real-Time Task
Software Scheduling – Part 2
Version 2 EE IIT, Kharagpur 1 Version 2 EE IIT, Kharagpur 2
Specific Instructional Objectives 1.1. Types of Event Driven Schedulers
At the end of this lesson, the student would be able to: We discuss three important types of event-driven schedulers:
x Simple priority-based
x Get an introduction to event-driven schedulers
x Rate Monotonic Analysis (RMA)
x Understand the basics of Foreground-Background schedulers x Earliest Deadline First (EDF)
The simplest of these is the foreground-background scheduler, which we discuss next. In
x Get an overview of Earliest Deadline First (EDF) Algorithm
section 3.4, we discuss EDF and in section 3.5, we discuss RMA.
x Work out solutions to problems based on EDF
x Know the shortcomings of EDF 1.2. Foreground-Background Scheduler
x Get an overview of Rate Monotonic Algorithm (RMA) A foreground-background scheduler is possibly the simplest priority-driven preemptive
x Know the necessary and sufficient conditions for a set of real-time tasks to be RMA- scheduler. In foreground-background scheduling, the real-time tasks in an application are
schedulable run as fore- ground tasks. The sporadic, aperiodic, and non-real-time tasks are run as
background tasks. Among the foreground tasks, at every scheduling point the highest
x Work out solutions to problems based on EDF priority task is taken up for scheduling. A background task can run when none of the
x Infer the maximum achievable CPU utilization foreground tasks is ready. In other words, the background tasks run at the lowest priority.
Let us assume that in a certain real-time system, there are n foreground tasks which are
x Understand the Advantages and Disadvantages of RMA denoted as: T1,T2,...,Tn. As already mentioned, the foreground tasks are all periodic. Let TB be
x Get an overview of Deadline Monotonic Algorithm (DMA) the only background task. Let eB be the processing time requirement of TB. In this case, the
completion time (ctB) for the background task is given by:
x Understand the phenomenon of Context-Switching and Self-Suspension n
ctB eB (1i=1¦ ei pi)
B B … (3.1/2.7)
This expression is easy to interpret. When any foreground task is executing, the background
1. Event-driven Scheduling – An Introduction
task waits. The average CPU utilization due to the foreground task Ti is eipi, since ei amount of
processing time is required over every pi period. It follows that all foreground tasks together
In this lesson, we shall discuss the various algorithms for event-driven scheduling. From the n
previous lesson, we may recollect the following points: would result in CPU utilization of i=1¦ ei pi. Therefore, the average time available for execution
n
The clock-driven schedulers are those in which the scheduling points are determined by the of the background tasks in every unit of time is 1i=1¦ ei pi. Hence, Expr. 2.7 follows easily.
interrupts received from a clock. In the event-driven ones, the scheduling points are defined by We now illustrate the applicability of Expr. 2.7 through the following three simple examples.
certain events which precludes clock interrupts. The hybrid ones use both clock interrupts as well
as event occurrences to define their scheduling points
Cyclic schedulers are very efficient. However, a prominent shortcoming of the cyclic 1.3. Examples
schedulers is that it becomes very complex to determine a suitable frame size as well as a
feasible schedule when the number of tasks increases. Further, in almost every frame some Example 1: Consider a real-time system in which tasks are scheduled using foreground-
processing time is wasted (as the frame size is larger than all task execution times) resulting background scheduling. There is only one periodic foreground task Tf : (If 0, pf 50 msec, ef
in sub-optimal schedules. Event-driven schedulers overcome these shortcomings. Further, event- 100 msec, df 100 msec) and the background task be TB (eB 1000 msec). Compute the
B B
driven schedulers can handle aperiodic and sporadic tasks more proficiently. On the flip side, completion time for background task.
event-driven schedulers are less efficient as they deploy more complex scheduling algorithms.
Therefore, event-driven schedulers are less suitable for embedded applications as these are Solution: By using the expression (2.7) to compute the task completion time, we have
required to be of small size, low cost, and consume minimal amount of power. ctB 1000 (150100) 2000 msec
B
It should now be clear why event-driven schedulers are invariably used in all moderate and So, the background task TB would take 2000 milliseconds to complete.
B
large-sized applications having many tasks, whereas cyclic schedulers are predominantly
used in small applications. In event-driven scheduling, the scheduling points are defined Example 2: In a simple priority-driven preemptive scheduler, two periodic tasks T1 and T2
by task completion and task arrival events. This class of schedulers is normally preemptive, and a background task are scheduled. The periodic task T1 has the highest priority and
i.e., when a higher priority task becomes ready, it preempts any lower priority task that may be executes once every 20 milliseconds and requires 10 milliseconds of execution time each
running. time. T2 requires 20 milliseconds of processing every 50 milliseconds. T3 is a background
task and requires 100 milliseconds to complete. Assuming that all the tasks start at time 0,
determine the time at which T3 will complete.
i=1
¦ ei min(pi, di) d 1 … (3.3/2.9)
However, if pi di, it is possible that a set of tasks is EDF schedulable, even when the task
Context Switching Time set fails to meet the Expr 3.3. Therefore, Expr 3.3 is conservative when pi di, and is not a
necessary condition, but only a sufficient condition for a given task set to be EDF schedulable.
Back Foreground Back Foreground
Foreground ground
ground
Example 4: Consider the following three periodic real-time tasks to be scheduled using EDF
01 51 52 100 Time in milli secs on a uniprocessor: T1 = (e1 10, p1 20), T2 = (e2 5, p2 50), T3 = (e3 10, p3 35). Determine
whether the task set is schedulable.
Fig. 30.1 Task Schedule for Example 3
Solution: The very first time the foreground task runs (at time 0), it incurs a context Solution: The total utilization due to the three tasks is given by:
3
switching overhead of 1 msec. This has been shown as a shaded rectangle in Fig. 30.1. i=1
¦ ei pi 1020 + 550 + 1035 0.89
Subsequently each time the foreground task runs, it preempts the background task and incurs This is less than 1. Therefore, the task set is EDF schedulable.
one context switch. On completion of each instance of the foreground task, the background Though EDF is a simple as well as an optimal algorithm, it has a few shortcomings
task runs and incurs another context switch. With this observation, to simplify our which render it almost unusable in practical applications. The main problems with EDF are
computation of the actual completion time of TB, we can imagine that the execution time of
B
discussed in Sec. 3.4.3. Next, we discuss the concept of task priority in EDF and then discuss
every foreground task is increased by two context switch times (one due to itself and how EDF can be practically implemented.
the other due to the background task running after each time it completes). Thus, the
net effect of context switches can be imagined to be causing the execution time of 1.4.1. Is EDF Really a Dynamic Priority Scheduling Algorithm?
the foreground task to increase by 2 context switch times, i.e. to 52 milliseconds from
50 milliseconds. This has pictorially been shown in Fig. 30.1. We stated in Sec 3.3 that EDF is a dynamic priority scheduling algorithm. Was it after all
Now, using Expr. 2.7, we get the time required by the background task to complete: correct on our part to assert that EDF is a dynamic priority task scheduling algorithm? If EDF
1000/(152100) 2083.4 milliseconds were to be considered a dynamic priority algorithm, we should be able determine the precise
In the following two sections, we examine two important event-driven schedulers: EDF priority value of a task at any point of time and also be able to show how it changes with time. If
(Earliest Deadline First) and RMA (Rate Monotonic Algorithm). EDF is the optimal dynamic we reflect on our discussions of EDF in this section, EDF scheduling does not require any
priority real-time task scheduling algorithm and RMA is the optimal static priority real-time task priority value to be computed for any task at any time. In fact, EDF has no notion of a priority
scheduling algorithm. value for a task. Tasks are scheduled solely based on the proximity of their deadline.
However, the longer a task waits in a ready queue, the higher is the chance (probability) of
1.4. Earliest Deadline First (EDF) Scheduling being taken up for scheduling. So, we can imagine that a virtual priority value associated with a
task keeps increasing with time until the task is taken up for scheduling. However, it is important
In Earliest Deadline First (EDF) scheduling, at every scheduling point the task having the to understand that in EDF the tasks neither have any priority value associated with them, nor
shortest deadline is taken up for scheduling. This basic principles of this algorithm is very does the scheduler perform any priority computations to determine the schedulability of a task at
intuitive and simple to understand. The schedulability test for EDF is also simple. A task set is either run time or compile time.
schedulable under EDF, if and only if it satisfies the condition that the total processor utilization
due to the task set is less than 1. For a set of periodic real-time tasks {T1, T2, …, Tn}, EDF 1.4.2. Implementation of EDF
schedulability criterion can be expressed as:
n n
i=1
¦ ei pi i=1¦ ui d 1 A naive implementation of EDF would be to maintain all tasks that are ready for execution in
… (3.2/2.8) a queue. Any freshly arriving task would be inserted at the end of the queue. Every node in the
A set of periodic real-time tasks would not be RMA schedulable unless they satisfy the Fig. 30.3 Achievable Utilization with the Number of Tasks under RMA
following necessary condition:
n n Evaluation of Expr. 3.4 when n o f involves an indeterminate expression of the type f.0.
¦ ei pi i=1¦ ui d 1
i=1 By applying L’Hospital’s rule, we can verify that the right hand side of the expression evaluates
where ei is the worst case execution time and pi is the period of the task Ti, n is the number of to loge2 0.692. From the above computations, it is clear that the maximum CPU utilization that
tasks to be scheduled, and ui is the CPU utilization due to the task Ti. This test simply expresses can be achieved under RMA is 1. This is achieved when there is only a single task in the system.
the fact that the total CPU utilization due to all the tasks in the task set should be less than 1. As the number of tasks increases, the achievable CPU utilization falls and as n o f, the
achievable utilization stabilizes at loge2, which is approximately 0.692. This is pictorially shown
1.5.1.2 Sufficient Condition in Fig. 30.3. We now illustrate the applicability of the RMA schedulability criteria through a few
examples.
The derivation of the sufficiency condition for RMA schedulability is an important result and
was obtained by Liu and Layland in 1973. A formal derivation of the Liu and Layland’s results 1.5.2. Examples
from first principles is beyond the scope of this discussion. We would subsequently refer to the
sufficiency as the Liu and Layland’s condition. A set of n real-time periodic tasks are Example 5: Check whether the following set of periodic real-time tasks is schedulable under
schedulable under RMA, if
n RMA on a uniprocessor: T1 = (e1 20, p1 100), T2 = (e2 30, p2 150), T3 = (e3 60, p3 200).
i=1
¦ ui d n(21/n 1) (3.4/2.10)
where ui is the utilization due to task Ti. Let us now examine the implications of this result. If a Solution: Let us first compute the total CPU utilization achieved due to the three given
set of tasks satisfies the sufficient condition, then it is guaranteed that the set of tasks would be tasks.
3
RMA schedulable. ¦ ui 20100 + 30150 + 60200 0.7
i=1
Consider the case where there is only one task in the system, i.e. n = 1.
This is less than 1; therefore the necessary condition for schedulability of the tasks is
Substituting n 1 in Expr. 3.4, we get, satisfied. Now checking for the sufficiency condition, the task set is schedulable under RMA
1 1
i=1
¦ ui d 1(21/1 1) or i=1¦ ui d 1 if Liu and Layland’s condition given by Expr. 3.4 is satisfied Checking for satisfaction of
Similarly for n = 2, we get, Expr. 3.4, the maximum achievable utilization is given by:
2 2 13
i=1
¦ ui d 2(21/2 1) or i=1¦ ui d 0.828 3(2 1) 0.78
For n = 3, we get, The total utilization has already been found to be 0.7. Now substituting these in Liu and
3 3 Layland’s criterion:
i=1
¦ ui d 3(21/3 1) or i=1¦ ui d 0.78 3 13
For n o f, we get, i=1
¦ ui d 3(2 1)
f f Therefore, we get 0.7 < 0.78.
i=1
¦ ui d 3(21/f 1) or i=1¦ ui d f.0
Expr. 3.4, a sufficient condition for RMA schedulability, is satisfied. Therefore, the task set
is RMA-schedulable
Example 6: Check whether the following set of three periodic real-time tasks is
schedulable under RMA on a uniprocessor: T1 = (e1 20, p1 100), T2 = (e2 30, p2 150), T3
= (e3 90, p3 200).
Solution: Let us first compute the total CPU utilization due to the given task set:
3
i=1
¦ ui 20100 + 30150 + 90200 0.7
A set of periodic real-time tasks is RMA schedulable under any task phasing, iff all the tasks For the task T1: e1 < p1 holds since 20 msec < 100 msec. Therefore, it would meet its first
meet their respective first deadlines under zero phasing. deadline (it does not have any tasks that have higher priority).
Deadline for T1
T1 T2 T1 T2 T1 T2 T1
T1 T2
T2 T1 T2 T1 T2
20 30 50 60 80 time in msec 20 50 150
(b) T2 meets its first deadline
(b) T1 has a 20 msec phase with respect to T2 Deadline for T3
Fig. 30.4 Worst Case Response Time for a Task Occurs When It is in Phase
with Its Higher Priority Tasks
T1 T2 T3 T1 T3 T2 T3
A formal proof of this Theorem is beyond the scope of this discussion. However, we provide an
intuitive reasoning as to why Theorem 3 must be true. Intuitively, we can understand this result 20 50 100 120 150 180 190 200
from the following reasoning. First let us try to understand the following fact. (c) T3 meets its first deadline
Ti(1) Example 8: Consider the following set of three periodic real-time tasks: T1 (10,20),
T2 (15,60), T3 (20,120) to be run on a uniprocessor. Determine whether the task set is
schedulable under RMA.
T1(1) T1(2) T1(3)
Solution: First let us try the sufficiency test for RMA schedulability. By Expr. 3.4 (Liu and
Layland test), the task set is schedulable if ¦ ui d 0.78.
¦ ui = 1020 + 1560 + 20120 = 0.91
Fig. 30.6 Instances of T1 over a single instance of Ti
This is greater than 0.78. Therefore, the given task set fails Liu and Layland test. Since Expr.
Let us now try to derive a formal expression for this important result of Lehoczky. Let {T1, 3.4 is a pessimistic test, we need to test further.
T2, …,Ti} be the set of tasks to be scheduled. Let us also assume that the tasks have been ordered Let us now try Lehoczky’s test. All the tasks T1, T2, T3 are already ordered in decreasing
in descending order of their priority. That is, task priorities are related as: pr(T1) > pr(T2) > … > order of their priorities.
Testing for task T1:
pr(Ti), where pr(Ti) denotes the priority of the task Ti. Observe that the task T1 has the highest
priority and task Ti has the least priority. This priority ordering can be assumed without any loss Since e1 (10 msec) is less than d1 (20 msec), T1 would meet its first deadline.
of generalization since the required priority ordering among an arbitrary collection of tasks can Testing for task T2:
always be achieved by a simple renaming of the tasks. Consider that the task Ti arrives at the 15 + ª6020º
10 d 60 or 15 + 30 = 45 d 60 msec
time instant 0. Consider the example shown in Fig. 30.6. During the first instance of the task Ti, The condition is satisfied. Therefore, T2 would meet its first deadline.
three instances of the task T1 have occurred. Each time T1 occurs, Ti has to wait since T1 has Testing for Task T3:
higher priority than Ti. 20 + ª12020º
10 + ª12060º
15 = 20 + 60 + 30 = 110 msec
Let us now determine the exact number of times that T1 occurs within a single instance of Ti. This is less than T3’s deadline of 120. Therefore T3 would meet its first deadline.
This is given by ªpi p1º. Since T1’s execution time is e1, then the total execution time required Since all the three tasks meet their respective first deadlines, the task set is RMA schedulable
due to task T1 before the deadline of Ti is ªpi p1º
e1. This expression can easily be generalized according to Lehoczky’s results.
to consider the execution times all tasks having higher priority than Ti (i.e. T1, T2, …, Ti1).
Example 9: RMA is used to schedule a set of periodic hard real-time tasks in a system. Is it
Therefore, the time for which Ti will have to wait due to all its higher priority tasks can be
possible in this system that a higher priority task misses its deadline, whereas a lower
expressed as:
i-1 priority task meets its deadlines? If your answer is negative, prove your denial. If your
k=1
¦ ªpi pkº
ek …(3.5/2.11) answer is affirmative, give an example involving two or three tasks scheduled using RMA
Expression 3.5 gives the total time required to execute Ti’s higher priority tasks for which Ti where the lower priority task meets all its deadlines whereas the higher priority task misses
would have to wait. So, the task Ti would meet its first deadline, iff its deadline.
i-1
ei + k=1¦ ªpi pkº
ek d pi …(3.6/2.12)
That is, if the sum of the execution times of all higher priority tasks occurring before Ti’s first Solution: Yes. It is possible that under RMA a higher priority task misses its deadline where
deadline, and the execution time of the task itself is less than its period pi, then Ti would as a lower priority task meets its deadline. We show this by constructing an example.
complete before its first deadline. Note that in Expr. 3.6, we have implicitly assumed that the Consider the following task set: T1 = (e1 15, p1 20), T2 = (e2 6, p2 35), T3 = (e3 3,
p3 100). For the given task set, it is easy to observe that pr(T1) > pr(T2) > pr(T3). That is, T1,
T2, T3 are ordered in decreasing order of their priorities.
Version 2 EE IIT, Kharagpur 13 Version 2 EE IIT, Kharagpur 14
For this task set, T3 meets its deadline according to Lehoczky’s test since However, since the task set is harmonically related, pi can be written as m
pk for some m.
e3 + ªp3 p2º
e2 + ªp3 p1º
e1 = 3 + ( ª10035º
6) + ( ª10020º Using this, ªpi pkº = pi pk. Now, Expr. 3.6 can be written as:
15) i-1
ei + k=1¦ (pi pk)
ek d pi
= 3 + (3
6) + (5
15) = 96 d 100 msec. n-1
But, T2 does not meet its deadline since For Ti = Tn, we can write, en + k=1¦ (pn pk)
ek d pn.
e2 + ªp2 p1º
e1 = 6 + ( ª3520º
15) = 6 + (2
15) = 36 msec. Dividing both sides of this expression by pn, we get the required result.
n n
This is greater than the deadline of T2 (35 msec). Hence, the task set would be schedulable iff k=1¦ ek pk d 1 or i=1¦ ui d 1.
As a consequence of the results of Example 9, by observing that the lowest priority task of a
given task set meets its first deadline, we can not conclude that the entire task set is RMA
schedulable. On the contrary, it is necessary to check each task individually as to
1.5.6. Advantages and Disadvantages of RMA
whether it meets its first deadline under zero phasing. If one finds that the lowest
In this section, we first discuss the important advantages of RMA over EDF. We then point
priority task meets its deadline, and concludes that the entire task set would be feasibly
out some disadvantages of using RMA. As we had pointed out earlier, RMA is very commonly
scheduled under RMA, he is likely to be flawed.
used for scheduling real-time tasks in practical applications. Basic support is available in almost
all commercial real-time operating systems for developing applications using RMA. RMA is
1.5.4. Achievable CPU Utilization simple and efficient. RMA is also the optimal static priority task scheduling algorithm. Unlike
EDF, it requires very few special data structures. Most commercial real-time operating systems
Liu and Layland’s results (Expr. 3.4) bounded the CPU utilization below which a task set support real-time (static) priority levels for tasks. Tasks having real-time priority levels are
would be schedulable. It is clear from Expr. 3.4 and Fig. 30.10 that the Liu and Layland arranged in multilevel feedback queues (see Fig. 30.7). Among the tasks in a single level, these
schedulability criterion is conservative and restricts the maximum achievable utilization due to commercial real-time operating systems generally provide an option of either time-slicing and
any task set which can be feasibly scheduled under RMA to 0.69 when the number of tasks in the round-robin scheduling or FIFO scheduling.
task set is large. However, (as you might have already guessed) this is a pessimistic figure. In
fact, it has been found experimentally that for a large collection of tasks with independent RMA Transient Overload Handling: RMA possesses good transient overload handling
periods, the maximum utilization below which a task set can feasibly be scheduled is on the capability. Good transient overload handling capability essentially means that, when a lower
average close to 88%. priority task does not complete within its planned completion time, it can not make any higher
For harmonic tasks, the maximum achievable utilization (for a task set to have a feasible priority task to miss its deadline. Let us now examine how transient overload would affect a set
schedule) can still be higher. In fact, if all the task periods are harmonically related, then even a of tasks scheduled under RMA. Will a delay in completion by a lower priority task affect a
task set having 100% utilization can be feasibly scheduled. Let us first understand when are the higher priority task? The answer is: ‘No’. A lower priority task even when it exceeds its planned
periods of a task set said to be harmonically related. The task periods in a task set are said to be execution time cannot make a higher priority task wait according to the basic principles of RMA
harmonically related, iff for any two arbitrary tasks Ti and Tk in the task set, whenever pi > pk, it whenever a higher priority task is ready, it preempts any executing lower priority task.
should imply that pi is an integral multiple of pk. That is, whenever pi > pk, it should be possible Thus, RMA is stable under transient overload and a lower priority task overshooting its
to express pi as n
pk for some integer n > 1. In other words, pk should squarely divide pi. An completion time can not make a higher priority task to miss its deadline.
example of a harmonically related task set is the following: T1 = (5, 30), T2 = (8, 120), T3 = (12,
60).
It is easy to prove that a harmonically related task set with even 100% utilization can feasibly
be scheduled.
1.5.5. Theorem 4
For a set of harmonically related tasks HS = {Ti}, the RMA schedulability criterion is given
n
by i=1¦ ui d 1.
Proof: Let us assume that T1, T2, …, Tn be the tasks in the given task set. Let us further
assume that the tasks in the task set T1, T2, …, Tn have been arranged in increasing order of their
periods. That is, for any i and j, pi < pj whenever i < j. If this relationship is not satisfied, then a
simple renaming of the tasks can achieve this. Now, according to Expr. 3.6, a task Ti meets its
i-1
deadline, if ei + k=1¦ ªpi pkº
ek d pi.
1.8. Self Suspension Solution: The tasks are already ordered in descending order of their priorities. By using the
generalized Lehoczky’s condition given by Expr. 3.9, we get:
A task might cause its self-suspension, when it performs its input/output operations or when it For T1 to be schedulable:
waits for some events/conditions to occur. When a task self suspends itself, the operating system (10 + 3) < 50
removes it from the ready queue, places it in the blocked queue, and takes up the next eligible Therefore T1 would meet its first deadline.
task for scheduling. Thus, self-suspension introduces an additional scheduling point, which we For T2 to be schedulable:
did not consider in the earlier sections. Accordingly, we need to augment our definition of a (25 + 6 + 10
3) < 150
scheduling point given in Sec. 2.3.1 (lesson 2). Therefore, T2 meets its first deadline.
For T3 to be schedulable:
In event-driven scheduling, the scheduling points are defined by task completion, task (50 + 11 + (10
4 + 25
2)) < 200
arrival, and self-suspension events. This inequality is also satisfied. Therefore, T3 would also meet its first deadline.
It can therefore be concluded that the given task set is schedulable under RMA even when
Let us now determine the effect of self-suspension on the schedulability of a task set. Let us self-suspension of tasks is considered.
consider a set of periodic real-time tasks {T1, T2, …, Tn}, which have been arranged in the
increasing order of their priorities (or decreasing order of their periods). Let the worst case
self-suspension time of a task Ti is bi. Let the delay that the task Ti might incur due to its own
1.9. Self Suspension with Context Switching Overhead
self-suspension and the self-suspension of all higher priority tasks be bti. Then, bti can be
Let us examine the effect of context switches on the generalized Lehoczky’s test (Expr.3.9)
expressed as:
i-1 for schedulability of a task set, which takes self-suspension by tasks into account. In a fixed
bti bi + k=1¦ min(ek, bk) …(3.8/2.15) priority preemptable system, each task preempts at most one other task if there is no self
Self-suspension of a higher priority task Tk may affect the response time of a lower priority task suspension. Therefore, each task suffers at most two context switches one context switch when
Ti by as much as its execution time ek if ek < bk. This worst case delay might occur when the it starts and another when it completes. It is easy to realize that any time when a task self-
higher priority task after self-suspension starts its execution exactly at the time instant the lower suspends, it causes at most two additional context switches. Using a similar reasoning, we can
priority task would have otherwise executed. That is, after self-suspension, the execution of the determine that when each task is allowed to self-suspend twice, additional four context switching
higher priority task overlaps with the lower priority task, with which it would otherwise not have overheads are incurred. Let us denote the maximum context switch time as c. The effect of a
overlapped. However, if ek > bk, then the self suspension of a higher priority task can delay a single self-suspension of tasks is to effectively increase the execution time of each task Ti in the
lower priority task by at most bk, since the maximum overlap period of the execution of a higher worst case from ei to (ei + 4
c). Thus, context switching overhead in the presence of a single
priority task due to self-suspension is restricted to bk. self-suspension of tasks can be taken care of by replacing the execution time of a task Ti by (ei +
Note that in a system where some of the tasks are non preemptable, the effect of self 4
c) in Expr. 3.9. We can easily extend this argument to consider two, three, or more self-
suspension is much more severe than that computed by Expr.3.8. The reason is that, every time suspensions.
a processor self suspends itself, it loses the processor. It may be blocked by a non-preemptive
lower priority task after the completion of self-suspension. Thus, in a non-preemptable scenario,
a task incurs delays due to self-suspension of itself and its higher priority tasks, and also the 1.10.Exercises
delay caused due to non-preemptable lower priority tasks. Obviously, a task can not get delayed
due to the self-suspension of a lower priority non-preemptable task. 1. State whether the following assertions are True or False. Write one or two sentences to
The RMA task schedulability condition of Liu and Layland (Expr. 3.4) needs to change when justify your choice in each case.
we consider the effect of self-suspension of tasks. To consider the effect of self-suspension in a. When RMA is used for scheduling a set of hard real-time periodic tasks, the upper
Expr. 3.4, we need to substitute ei by (ei + bti). If we consider the effect of self-suspension on bound on achievable utilization improves as the number in tasks in the system being
task completion time, the Lehoczky criterion (Expr. 3.6) would also have to be generalized: developed increases.
Start Time Processing Time Period Deadline a. Check whether the three given tasks are schedulable under RMA. Show all
Task intermediate steps in your computation.
mSec mSec mSec mSec
b. Assuming that each context switch incurs an overhead of 1 msec, determine whether
T1 20 25 150 100 the tasks are schedulable under RMA. Also, determine the average context switching
T2 60 10 50 30 overhead per unit of task execution.
c. Assume that T1, T2, and T3 self-suspend for 10 msec, 20 msec, and 15 msec
T3 40 50 200 150 respectively. Determine whether the task set remains schedulable under RMA. The
context switching overhead of 1 msec should be considered in your result. You can
Determine whether the task set is schedulable on a uniprocessor using EDF. Show assume that each task undergoes self-suspension only once during each of its
all intermediate steps in your computation. execution.
14. Determine whether the following set of periodic real-time tasks is schedulable on a d. Assuming that T1 and T2 are assigned the same priority value, determine the
uniprocessor using RMA. Show the intermediate steps in your computation. Is RMA additional delay in response time that T2 would incur compared to the case when they
optimal when the task deadlines differ from the task periods? are assigned distinct priorities. Ignore the self-suspension times and the context
switch overhead for this part of the question.