2.2 Real-time Systems
2.2.2 Real-time scheduling
There are several scheduling policies available in real-time scheduling and each of them are better suited for different task types. We present two such widely used policies that are proven optimal for certain scenarios [Liu and Layland,1973].
Rate Monotonic
Rate Monotonic (RM) is an optimal fixed priority scheduling policy where priorities are assigned to tasks based on the frequency of occurrence. Therefore, this scheduling policy is ideal for recurring tasks where the frequency is known apriori. Herein, priori- ties are assigned (fixed) and order of execution is decided prior to the start of execution. RM is considered as an optimal static algorithm, in a sense that no other fixed priority algorithm can schedule a task set that cannot be scheduled by it. However, its schedu- lable bound is less than 100%. Schedulable bound is the maximum Central Processing Unit (CPU) utilisation level achieved by a set of tasks, up to which deadlines of all tasks is guaranteed to be met. While the policy works well with periodic tasks, it could be disrupted by aperiodic and sporadic tasks in the system.
For a given Taskτi, with a worst case execution time is Ci, a period of Pi, the fraction
of CPU time spent in processingτi is Ci/Pi. The total CPU time spent in executing n
tasks is: U = n X i=1 Ci/Pi
According to [Liu and Layland,1973] the worst case schedulable bound Wifor n tasks
is:
CHAPTER 2. BACKGROUND
IfPn
i=1Ci/Pi ≤ n(21/n− 1), where n is the number of tasks to be scheduled, then the
RM policy will schedule all the tasks to meet their respective deadlines. RM policy has a complexity of O((N +α)2) in the worst case, where N is the total number of requests
in the hyper period of n periodic tasks in the system andα is the number of aperiodic
tasks in the system [Mohammadi A. and Akl S. G.,2005].
Earliest Deadline First
The EDF scheduling policy considers deadlines of tasks in assigning priorities. The priorities of tasks are not decided at design time (as in the case of RM) and can change dynamically at runtime. Priorities are typically assigned to tasks on their arrival at the system. However the arrival of a task could result in a change of priorities in the tasks already in the system. The deadline based priority system means that a higher priority task with an earlier deadline could preempt a lower priority task. As a result, the order of execution may change at any time. This process results in a higher scheduling overhead in EDF compared to a static policy such as RM. However, these characteristics also make EDF a better choice for systems with aperiodic and sporadic tasks. Moreover, such features enable EDF to achieve a schedulable bound of 100% for all tasks. EDF is considered as an optimal dynamic algorithm, in a sense that no other dynamic priority algorithm can schedule a task set that cannot be scheduled by it. However, one drawback of EDF is that there is no guarantee of which task would fail in overload conditions, whereas with RM lower priority tasks will always fail in overload conditions.
For a given Taskτi, with a worst case execution time of Ciand a period of Ti, If
n X
i=1
(Ci/Ti) ≤ 1 (2.2.1)
where n is the total number of tasks, it is feasible to schedule the set of tasks to success- fully meet their deadlines. In other words, if the total CPU utilisation of the task set is less than or equal to 100%, it is deemed feasible to use EDF to schedule the set of tasks. EDF has a complexity of O((N +α)2) in the worst case, where N is the total number of requests in the hyper period of n periodic tasks in the system andα is the number of
aperiodic tasks in the system [Mohammadi A. and Akl S. G.,2005].
CHAPTER 2. BACKGROUND
ware to achieve predictability of service execution. Herein, the greater challenge is to use scheduling policies typically used in closed systems where most task properties are known apriori, in a highly dynamic environment where task properties are not known. The unknown nature of web service requests means that tasks will be aperiodic and the best scheduling policy for such tasks will thus be EDF. Therefore, next we dwell further into important concepts behind EDF scheduling.
On a uni-processor system, assuming a non-idling and a non-preemptive system, if all tasks are ready at time t=0,
Theorem 1 (Jackson’s Rule [Jackson,1955]) Any sequence is optimal that puts the
jobs in order of non-decreasing deadlines.
For a uni-processor system, having tasks with arbitrary release times, deadlines, exe- cution times or unknown execution times,
Theorem 2 ([Dertouzos,1974]) The EDF algorithm is optimal in that if there exist
any algorithm that can build a valid (feasible) schedule on a single processor, then EDF algorithm also builds a valid (feasible) schedule.
Any valid schedule (a set of tasks that could be successfully scheduled within a given time period) can be converted into a valid EDF schedule by using a ‘time slice swapping’ technique, where the order of tasks are interchange to arrive at an EDF schedule. Figure
2.7illustrates this with a simple example. The example contains 3 tasks executed within a 20 time unit interval. This is assumed to be a synchronous schedule (i.e. all tasks share the same start time of t=0). Task T1 has a deadline of 20 time units and an execution time of 8 time units, T2 has a deadline of 18 time units and an execution time of 3 time units and T3 a deadline of 17 time units and an execution time of 5 time units. In the given schedule, the task with the earliest deadline (T3), gets the CPU last.
When converting this to an EDF based schedule, the time slice of task T1, is swapped with the time slices of tasks T2 and T3. As T3 has the earliest deadline, it is executed first, followed by T2 and then by T1. The schedule with 3 tasks is transformed into a valid EDF based schedule, meeting the deadlines of all 3 tasks.
CHAPTER 2. BACKGROUND 0 8 1 1 1 71 8 2 0 T1 T2 T3 1 6 0 5 8 1 7 1 8 2 0 T1 T2 T3 1 6
Figure 2.7: Transformation of a valid schedule to an EDF based valid schedule
The optimality of a real-time deadline based scheduling algorithm such as EDF is en- sured by schedulability analysis (depicted in equation2.2.1), a step carried out offline. Taking execution time requirements of tasks into consideration, this aids in analysing the feasibility of a schedule. As it is meant to be worked offline, it renders itself unsuit- able in a web services scenario. However, certain principles it is based on can be used in devising a suitable online feasibility analysis (which is discussed in Chapter3).
Two concepts considered in schedulability analysis, namely processor demand and
loading factor [Stankovic et al.,1998] are defined here. Henceforth, we use a given taskTi, with release time ofri, a deadline ofdi and an execution time requirement of Ci. Our proposed model for schedulability analysis (presented in Chapter3) is based
on the following definitions.
Definition 1 For a given set of real-time tasks and a semi-closed interval of time[t1, t2),
the processor demand (h) for the set of tasks in the interval [t1, t2) is
h[t1,t2)=
X
t1≤rk,dk≤t2
CHAPTER 2. BACKGROUND
Definition 2 For a given set of real-time tasks the fraction of the semi-closed interval
[t1, t2) needed to execute its tasks is considered as its loading factor (u) that is, u[t1,t2)=
h[t1,t2) t2− t1
. (2.2.3)
Definition 3 The loading factor of the maximum of all such intervals, is considered as
absolute loading factor, that is,
u = sup 0≤t1≤t2
u[t1,t2). (2.2.4)
As an example, applying these to the tasks in the EDF schedule obtained in Figure2.7,
u[0,7) = 57 u[0,10) = 5+310 = 108 u[5,16) = 3+816 = 1111 u[0,16) = 5+3+816 = 1616 u[0,20) = 5+3+816 = 1620 u = 1616 = 1
Table 2.1: Loading factor computation for the job set of EDF schedule in Figure2.7
Theorem 3 ([Spuri,1995]) Any set of real-time tasks is feasibly scheduled by EDF
algorithm only if
u ≤ 1. (2.2.5)