of the CPU resource. This latter is not the case with static priority schemes such as the rate monotonic algorithm, although static schemes typically incur less run ...
Scheduling and Admission Testing for Jitter Constrained Periodic Threads: Discussion and Proof Andreas Mauthe and Geoff Coulson Distributed Multimedia Research Group, Department of Computing, Lancaster University, Lancaster LA1 4YR, UK. telephone: +44 (0)524 65201 e-mail: [andreas,geoff]@comp.lancs.ac.uk ABSTRACT We present new admission tests for periodic real-time threads with explicitly stated deadlines scheduled according to the earliest deadline first (EDF) algorithm. In traditional real-time periodic scheduling, the deadline of a periodic thread is conventionally the end of the current period. In contrast, our tests support periodic threads in which the deadline may be earlier than the end of the current period. In the extreme case, the deadline may be specified as identical to the per period execution time, which results in perfectly isochronous periodic threads. The provision of such threads, which we refer to as jitter constrained threads, helps end-systems to honour jitter- as well as throughput-related QoS parameters in distributed multimedia systems. In addition, such threads can reduce end-toend delay and buffer memory requirements as less buffering is needed to smooth excessive delay jitter.
1. Introduction Proposals for multimedia communications systems use quality of service (QoS) parameters to specify required levels of throughput, end-to-end delay and delay jitter. However, if these QoS parameters are to be delivered to application programs running on conventional workstations/ PCs, there must also be appropriate support from the operating system. Unfortunately, present day operating systems (e.g. UNIX) are far from ideal in supporting QoS: their CPU scheduling policies emphasise fairness and responsiveness at the expense of predictability [Nieh,93; Mauthe,92], their internal architectures emphasise backward compatibility at the expense of efficient data movement, and their memory managers emphasise large virtual address spaces at the expense of predictable memory access latency [Steinmetz,95]. In this paper, we address the issue of real-time CPU scheduling in operating systems (the same techniques are also potentially applicable in network switches and routers). Our approach is to design new admission tests for periodic real-time threads which guarantee that a run time scheduler (say an earliest deadline first scheduler) will be able to honour all specified deadlines where the specified deadlines may be earlier than the end of the current period. For periodic tasks it was traditionally assumed that the deadline is equal to the end of the period - even where the required CPU time is tiny compared to the period length. We refer to threads whose deadlines and periods may differ as jitter constrained threads because they exhibit less jitter (i.e. variation in periodicity) than conventional periodic threads. In fact, in the extreme case, where the deadline is specified to be identical to the execution time, a jitter constrained thread executes perfectly isochronously. Jitter constrained threads are particularly appropriate for high quality continuous media applications such as video and animation playouts as the display jitter
of high quality video or animation can be reduced to an arbitrary degree 1. The provision of jitter constrained threads also helps end-systems honour delay and jitterrelated QoS parameters. To see how delay and buffering requirements are affected, consider an application sending large video frames over a network using a rate based transport protocol. This scenario may be realised as a periodic thread t1 which executes application code to generate video frames, and another periodic thread t2 which performs fragmentation and transmits fragments at a fixed rate. With conventional real-time periodic threads, the delay incurred by this two thread system would be the sum of the period of t1 plus f times the period of t2 (where f denotes the number of packets per frame). However, if we are able to specify an earlier deadline for t1, the delay (and hence buffering requirement) can be significantly reduced. The top part of figure 1 shows the timing (for f=3) of this scenario in the conventional case: t2 can only assume that a frame is ready for fragmentation at the end of a frame generation period. In the bottom part of figure 1, t1 is a jitter constrained thread which completes the generation of a frame within one time unit of the start of a frame period (the solid segments in the t1 time line show the extent of the deadline and the dotted segments show the extent of the period). It can be seen that significant delay reductions are achieved. start generating frame t1 t2 delay start generating frame t1 t2 delay
deliver frame to network
deliver frame to network
Figure 1: Reducing delay with jitter constrained threads The remainder of this paper is structured as follows. Section 2 provides some background on the SUMO project in which the current research was carried out, and outlines the more general QoS support framework in which the particular mechanisms described in this paper are embedded. Section 3 then describes our proposed admission tests for jitter constrained threads. We show how our tests are related to the classic test in [Liu,73] and explain their derivation. In section 4 we evaluate our proposals through an analysis of the computational complexity of the tests and the additional run time overhead incurred. Finally, in section 5 we review some related work and in section 6 present our conclusions.
2. Background on SUMO The aim of the SUMO project is the design and implementation of a microkernel based operating system support infrastructure for distributed multimedia applications. We are interested in both communications and processing support for distributed multimedia applications in end systems, and believe that such applications require thread-to-thread realtime support according to user supplied quality of service (QoS) parameters. Such support, depending on the level of QoS commitment required (e.g. either guaranteed or best effort), may require dedicated, per-connection, resources and ongoing dynamic QoS management in the 1
Although it is possible to achieve jitter free playout with the assitance of harware generated periodic interrupts, this is not a sufficiently general solution.
2
CPU scheduler, virtual memory system and communication system. It is also important to us to be able to support standard UNIX applications on the same machine as our multimedia support infrastructure; we do not want to build a specialist real-time system isolated from the standard application environment. To achieve these ends we use the Chorus microkernel [Bricker,91] as a vehicle for our research. Chorus allows us to run UNIX applications via a SVR4 compatible UNIX ‘personality’ known as Chorus/MiX, and also provides rudimentary real-time support to native Chorus applications. We have designed our distributed multimedia support system as a Chorus personality implemented partly in kernel space and partly as a user level library to be linked with native Chorus applications. The personality provides a QoS driven application programmer’s interface (API), connection oriented communications with dedicated, perconnection, resources, and facilities for monitoring and maintaining ongoing QoS levels. The CPU scheduling work described in this paper is part of a broader resource management framework that also considers communications and memory resources. At connect time, a resource allocation protocol performs admission testing for all three resource types in both end-systems and intermediate network nodes. The resource requirements of connections are derived from QoS parameters supplied by the user. Our CPU scheduler is structured in a split level fashion [Govindan,91] with co-ordinated user level and kernel level schedulers. It supports both guaranteed commitment (admission tested) and best effort commitment (not admission tested) periodic threads. Each of these commitment classes contain either jitter constrained threads or ‘workahead’ threads (the latter run faster than their nominal rate when resource availability permits). Details of aspects of the SUMO resource management framework not covered in this paper are given in [Coulson,95].
3. Admission Testing of Jitter Constrained Threads 3.1 Periodic Scheduling Concepts Figure 2 illustrates the key periodic scheduling concepts of deadline, period and execution time. The abbreviations shown, i.e. d for deadline, p for period and e for execution time, are employed throughout this paper. The figure also illustrates the notions of scheduling time, i.e. instants at which quanta1 are deemed schedulable, jitter, i.e. the range of legal and possible completion times of quanta, and active span, i.e. the time between the start of a period and its corresponding deadline. deadline (d)
scheduling deadline (d) time
period (p) jitter
active span
execution time or quantum (e)
Figure 2: Periodic scheduling concepts 3.2 Earliest Deadline First Scheduling Our scheduling approach is principally based on the dynamic earliest deadline first (EDF) algorithm [Liu,73]. EDF scheduling is typically applied to periodic threads and assumes that the deadline of each periodic execution of a thread is equal to the end of its current period. The algorithm can be simply expressed as follows: Every time a thread becomes runnable, or a quantum finishes, select the runnable thread with the earliest deadline to run next. 1
We use the term quantum to refer to individual invocations of periodic threads. The term is used in preference to the term task as the latter is often ambiguously applied to mean both the thread as a whole and individual invocations of the thread.
3
EDF is an attractive policy as it is guaranteed to find a valid schedule (i.e. one that honours the deadlines of all threads) if such a schedule exists. It is also guaranteed to make maximal use of the CPU resource. This latter is not the case with static priority schemes such as the rate monotonic algorithm, although static schemes typically incur less run time overhead [Mauthe,92]. In their classic 1973 paper, Liu and Layland showed that periodic threads with deadlines equal to periods can be scheduled using EDF without violating any deadline if the sum of the per-period utilisations of each thread does not exceed unity. The per-period utilisation of a thread is defined as the ratio of its quantum length to the time available for execution of each quantum (i.e. the period length) and is effectively a measure of the percentage of the CPU resource that a thread needs in each period. If the total processor utilisation is not greater than 100% at any instant, the thread set can be safely scheduled. More formally, the admission test is expressed as follows: #t
∑e
i
i =1
pi
≤ 1
Here, #t is the number of threads in the system, ei is the execution time of each quantum of thread i, and p i is the period of thread i. If, as determined by the formula, processor over utilisation does not occur, then a valid schedule exists which EDF is guaranteed to find. 3.3 Extension Utilising Deadlines and Periods 3.3.1 Exploiting Deadlines and Periods To consider explicit dealines a first, naive, approach would be to replace pi in the Liu/ Layland formula by the deadline di. The problem here is that, although it will never admit a thread which cannot be correctly scheduled so as to meet its jitter constraints, such a test will often refuse to admit thread sets that EDF could nevertheless find a valid schedule for. Consider, for example, the following thread set. t1 : p = 3, d = 1, e = 1 t2 : p = 5, d = 4, e = 2
This set will not pass the above admission test even though a valid schedule can easily be found that will honour the deadlines of both threads. In figure 3, it can be seen that every time the scheduling time of t1 is reached, it is scheduled immediately by EDF because either it has a closer deadline than t2, or t2 has already finished processing when t1 becomes ready.
t1 t2
p1
p1 d2 p2
p1 d2 p2
p1
p1 = p2
p1
d2
d2
Figure 3: Deadline scheduling of jitter constrained threads In the time span between the start of a quantum of t2 and its deadline, t1 requires a maximum processing time of 2 units. Since the quanta of t2 must finish within 4 units of the start of each period and only require 2 units of execution time, the requirements of the quanta of both threads can be met within 4 units. Thus the resource will never be over utilised and EDF
4
produces a valid schedule. 3.3.2 The Extended Admission Test We can use the above example to extract the following general insight: A candidate thread can be accepted if, in the active span of each of its quanta, there is sufficient spare resource to schedule the required number of quanta of all other threads with an earlier or equal deadline -- even when the scheduling times of all threads concerned happen to coincide. Relating this to figure 3, we can see that, in a system currently supporting only t1, it should also be possible to support t2. This is because, in the active span of each of the quanta of t2 (i.e. 4 time units), it is possible to fit the required number of quanta of t1 (i.e. 2 quanta of 1 time unit each) and the quantum of t2 itself (i.e. 2 time units) - even when the scheduling times of quanta of t1 and t2 coincide. As 2 + 2 ≤ 4 we can say that it is permissible to admit t2. This argument is more formally captured in the following admission test. ∀ci in cmin , ..., cmax ,
k
∑ etime( j,
di ) di ≤ 1
j =1
(1)
e j , if t ≥ p j t p j + d j where etime( j, t) = e j t p j + e j (t − p j t p j ), otherwise dj In formula (1), the inequality is applied iteratively over an ordered sequence of deadline equivalence classes and must hold for all these classes. Each deadline equivalence class ci contains all threads in the system that have a deadline di, and the sequence of classes as a whole is ordered smallest deadline first to largest deadline last. The function etime(j, t) gives the maximum processing time required by a thread j in some time span t. The first subterm of etime considers any execution time incurred during all full periods of thread j that can occur during t. The second subterm considers the execution time to be taken into account where a period overlaps the end of t. The top condition of the second subterm is applicable where the whole active span of j falls within interval t. The bottom condition is applicable where only a portion of the active span falls within t . Given this definition of etime, it can be seen that the numerator of (1) sums the required execution times of some number of threads within the period d i. More specifically, the summation ranges over (1..k) which is defined to contain all threads in deadline classes up to and including the current class ci. The numerator as a whole thus evaluates to the total CPU time required, in the worse case, in the time interval di by all threads with a deadline ≤ di. To ensure that over-utilisation does not take place, this quantity, when divided by di itself, must be less than or equal to 1. Since EDF will always find a valid and optimal schedule in these circumstances, all threads of deadline ≤ di will be executed according to their jitter constraints. The reason why this admission test is less conservative than the naive approach alluded to in section 3.3.1 is that is uses more information on which to base its decision. More specifically, it exploits knowledge of the periods of the threads in addition to knowledge of deadlines. Note that this distinction is not recognised by the run time scheduler which continues to operate simply on the basis of deadlines as described in section 3.2. A full proof of formula (1) is given in Appendix 1.
5
3.4 Extension Utilising Predictable Scheduling Times 3.4.1 Exploiting Predictable Scheduling Times A limitation of test (1) is that it pessimistically assumes that all threads can (in the worse case) reach their scheduling times at the same instant. Where it can be demonstrated that this cannot occur, a further degree of freedom in admission testing is possible. For example, due to the implicit timing relationship between threads t1 and t2 in figure 1, it is only possible for their quanta to coincide at certain fixed instants. This is so because the scheduling times of quanta of t2 are always located at a fixed offset from the deadlines of quanta of t2. To see more clearly how such timing relationships can lead to schedules not possible under the assumptions of admission test (1), consider the following thread set:t1 : p = 3, d = 1, e = 1 t2 : p = 6, d = 1, e = 1 t3 : p = 12, d = 1, e = 1
This set would be rejected by admission test (1) as the maximum utilisation (required when the scheduling times of all three threads coincide) is 3. However, if we stipulate that the scheduling times of quanta of t2 will always follow deadlines of quanta of t1, and that the scheduling times of quanta of t3 will always follow deadlines of quanta of t2, then the valid schedule illustrated in figure 4 can be arrived at. This example works out because the threads form a so-called harmonic set [Kuo,91]. A harmonic set is a thread set in which the constituent threads can be ordered such that the period of each thread integrally divides its successor; i.e. in the above case 3 divides 6 divides 12. t3 t2
t1
Figure 4: Scheduling of threads belonging to a harmonic set The handling of hierarchically encoded MPEG video streams [Steinmetz,94] is another example of a scenario in which timing relationships between threads can be exploited. Consider an application where the I, P and B frames of an MPEG stream arrive on separate connections and are thus serviced by separate threads 1 . Assume that thread t I handles the I frame connection, tP handles the P frame connection and tB handles the B frame connection. Further assume that the sequence of arriving frames is IPBBPBBPBB IPBBPBBPBB... First note that without jitter constrained threads, in the worst case a quantum of tI is finished just before the start of its next period, therefore the processing of all P and B frames belonging to the same picture group have to be delayed so that the delay incurred is at least equal to the repetition period of tI. 1
Researchers propose that, in a video dissemination environment, the I, P and B frames of such streams be sent over separate connections so that different clients can choose a high or low quality picture depending on their specific needs and capabilities. For example, a client requiring high quality video would receive the data on all three connections whereas a low quality client would receive only on the I frame channel [Yeadon,94].
6
To ensure minimal delay, the processing associated with the I frame connection must be finished in time to allow the processing of the other connections to complete before the arrival of the next I frame. This requires that the deadline of quanta of tI that precede quanta of tP must be set to the arrival time of the following quantum of tP. Similarly, the deadline of quanta of tP that precede quanta of tB must be set to the arrival time of the following quantum of tB. Given these constraints, processing of any frame can start immediately on arrival. As with the example of figure 4, this arrangement ensures that the scheduling times of the three threads cannot coincide and thus less processor utilisation is incurred than would be the case if the three threads were independent1. It is important to note that the run time scheduler must ensure that the required timing relationships are actually maintained at run time. The rule followed by the run time scheduler is, at each decision point, to choose the thread with the earliest deadline from among those whose scheduling time has already arrived. If the scheduler were to consider threads whose scheduling times had not arrived, the thread set may no longer be schedulable. 3.4.2 The Extended Admission Test In admission test (2) (shown below) we recognise sets of threads with pre-defined timing relationships as described above; the test is a relatively straightforward extension of test (1). #H k ∀ci in cmin , ..., cmax ∑ etime( j, di ) + ∑ EH di ≤ 1 (2) j =1 H =1
The differences from (1) are, first, that the original term in the numerator now only considers those threads that are not placed in a harmonic set2, and, second, that a new term is added to express the maximum required processing time of any harmonic sets in the thread set. The expression EH represents the maximum processing time requirement over any interval di for the subset of threads in a harmonic set H whose deadlines are ≤ di. The summation to #H ranges over the set of harmonic sets. To understand the derivation of E H , refer to figure 5 which illustrates a harmonic set containing three threads with deadlines ≤ di. The double arrowed lines in figure 5 represent the active spans of the quanta of the associated threads. Intuitively, to find EH, the strategy is to ‘slide’ the interval di along the time line, repeatedly calculating the processing time requirement of the subset of the harmonic set whose deadlines fall within the current di interval. We then take the maximum of the required processing times of all these intervals to obtain EH. T B
A
...
U V C D t3
E
W F
X Y Z G
...
t2
t1 point 0
di
slide...
Figure 5: Resource utilisation of harmonic sets 1
2
Note, however, that although threads tI, tP and tB have implicit timing relationships, they do not form a harmonic set because of the nature of the repeating pattern (the ‘virtual periods’ of the threads are 10, 3, and 1 respectively). In this section, we use the term harmonic set loosely to cover both true harmonic sets and sets of threads with strictly non harmonic timing relationship such as those in the MPEG example of section 3.5.1.
7
When ‘sliding’ the interval di along the time line, it is sufficient to consider those intervals of length di which either start at the beginning of an active span or end at the end of an active span (it is not necessary to consider time spans starting at other times because the actual utilisation only changes at the start and end of an active span). We shall refer to the set of instants at which active spans start (i.e. {A, B, C, ..., G} in figure 5) as S, and refer to the members of this set as Si. Similarly, we shall refer to the set of instants at which active spans end (i.e. {T, U, ..., Z}) as the set D with members Di. Given these definitions, we denote by ES the set of processing times required over the interval di starting at instants in S. Similarly, we denote by ED the set of processing times required over the interval di ending at instants in D. Given these definitions, we can obtain EH by taking the maximum of the union of sets ES and ED to calculate the worse case processing time of members of the harmonic set H with deadlines ≤ di in any interval di. Thus: EH = max{ES U ED } The detailed procedures necessary to evaluate the sets ES and ED for a given value of di are presented in Appendix 2. 3.5 Summary The following table summarises the characteristics of the three admission tests for jitter constrained threads presented in this section. Admission test standard EDF test (1) for jitter constrained threads test (2) for jitter constrained threads
Information used by admission test period (=deadline), execution time deadline, execution time, period deadline, period, execution time, harmonic sets
Information used by run-time scheduler period (=deadline) deadline (optionally, scheduling time) deadline, scheduling time
Figure 6: Summary of admission test characteristics At admission test time, whereas the standard EDF test needs only knowledge of the deadline (i.e. the end of the period) of each quantum, both the jitter constrained admission tests require additional information. Furthermore, test(2) exploits more information than test one reflecting its increased sophistication and flexibility. Similarly, at run time, whereas standard EDF schedulers only need knowledge of periods (which equal deadlines), schedulers for test (2) also need to consider the scheduling time of each quantum. This is necessary to maintain the correct sequencing between members of harmonic sets as discussed above. Schedulers for test (1) can optionally consider scheduling times depending on the strength of real-time guarantee required. If it is only required that quanta complete before their deadlines then it is not necessary to consider scheduling times. If, on the other hand, it is considered as undesirable to complete too early as it is to complete too late, then scheduling times must be taken into account by the scheduler to prevent unwanted ‘workahead’.
4. Discussion and Evaluation 4.1 Admission Test Overheads The worse case complexity of test (1) is O(n2), where n represents the number of threads in the candidate thread set. This is because for each deadline equivalence class with deadline di, each thread with a deadline ≤ di must be considered; the worse case overhead occurs when all
8
threads in a candidate set have unique deadlines. Test (2) is O(n2) for the non-harmonic part of the formula. On top of this there is the overhead incurred by the calculation of max{ES union E D }. This is not a simple function of n but is additionally dependent on the relationships between the members in harmonic sets. For harmonic sets in the strict sense it can be expressed, for each harmonic set, as 2∗ ∑ ( pH pi ) where p H is the longest period of any ∀ i∈H
member of the harmonic set. Superficially, these complexity measures would seem to indicate serious limitations of tests (1) and especially (2). In practice, however, there is unlikely to be a requirement for a large number of jitter constrained threads per CPU. The overhead of even test (2) is still likely to be quite acceptable when of the order of tens or hundreds of threads are involved - particularly as the overhead is only incurred on thread creation. Furthermore, it is likely that application policy would dictate that the number of permissible jitter constrained threads per CPU be limited. In the SUMO design, for example, it is intended that most threads in a multimedia application context be workahead threads with best effort commitment [Coulson,95]. An additional issue is that test (2) assumes that the candidate thread set is already partitioned into an appropriate set of harmonic sets. Unfortunately, it is often the case that a given thread set can be partitioned into more than one set of harmonic sets some of which are schedulable and others of which are not (some intial work on how to determine harmonic sets was presented in [Kuo,91]). Although it is possible in principle to have the system attempt to recognise sets this, in the general case, is problematic as it would considerably impact the run time complexity of the admission test. The alternative, i.e. requiring the user to explicitly notify harmonic sets, is also problematic in that it places an additional burden on the user 1. A possible compromise is to leave the responsibility for identifying harmonic sets to the system but only attempt to identify sets containing one or two distinct periods. The special case of sets containing multiple threads with a single, identical, period is likely to be quite common as applications frequently open multiple instances of a given connection type (e.g. multiple video connections). It may also be possible to force thread sets into harmonic relationships by slightly altering periods in consultation with the user.
Figure 7: Improved harmonic set scheduling A related issue is the choice of a suitable run time sequencing of the threads in a harmonic set. Figure 4 showed that members of the example thread set of section 3.4.1 were schedulable when the sequencing of the threads was according to period length, i.e. the thread with the shortest period was scheduled first, the thread with the next shortest period second (at the deadline of the previous thread), etc. Unfortunately, although a useful heuristic, this simple strategy is not always optimal. For example, figure 7 shows how, by following an alternative sequencing strategy, it is possible to schedule one instance of t1 along with two instances of t2 and four instances of t3 whereas only one instance of each thread was schedulable using the heuristic of section 3.4.1. The question of how best to select scheduling time relationships
1
Of course it is necessary to do this anyway when it is required to exploit non harmonic timing relationhips between threads as in the MPEG example of section 3.4.1.
9
among the threads in a harmonic set is still an open issue1. 4.2 Run-time Scheduling Overheads In addition to the admission test overhead discussed above, adaptations of the EDF runtime scheduler appropriate to admission tests (1) and (2) incur additional overheads at run time due to their consideration of scheduling times in addition to deadlines. To begin with, in addition to calculating the new deadline on completion of each quantum (new deadline := old deadline + period), these schedulers must also calculate the new scheduling time of each quantum. Initially, it might be thought that the calculation overhead of scheduling times for test (2) might be greater than that for test (1) as calculation of the former depends on other threads in the same harmonic set whereas the latter is dependent only on a single thread. However, the difference is only significant for the first quantum of each thread where the initial scheduling time of a thread in a harmonic set is time 0 + the thread’s initial offset. Subsequent calculations of scheduling time are relative to the scheduling time of the previous quantum as is the case with test (1). In both cases, then, the calculation is simply new scheduling time := old scheduling time + period. Note, however, that in the case of timing relationships within thread sets that do not form harmonic sets (see section 3.5.1), the overhead will be greater than this. Any further addition to the above overhead is dependent on the data structures used in the scheduler implementation. One possible scheme involves maintaining, in addition to the standard EDF ready queue (sorted by deadline), an additional waiting queue sorted by scheduling time. In this scheme a timer is set to fire at the scheduling time of the head thread on the waiting queue, so that thread(s) can be moved to the ready queue when they have become schedulable (the timer and queue transfer can be cheaply implemented as part of the system timer interrupt service routine). The overhead here is that each thread must be inserted into an ordered queue twice per quantum rather than once (i.e. first into the waiting queue and later into the ready queue). As the complexity of queue insertion is O(log n) (assuming a tree structured queue), almost twice as much time is necessary for queue insertion even though the two queues will be, on average, half the length of the single queue maintained by standard EDF. An alternative scheme for selecting the next thread is to maintain only the standard EDF queue (sorted by deadline), and to have the scheduler search the queue from the front until it finds a thread whose scheduling time has arrived. This algorithm incurs the same queue insertion overhead of standard EDF but adds overhead on thread selection 2. A key drawback is that, unlike the above scheme, it imposes overheads even on non jitter constrained threads (i.e. those whose scheduling time is always now). In this respect, the first scheme is superior in an environment of mixed thread classes (such as SUMO). It seems more reasonable to pay extra for the benefits of jitter constrained threads when other thread classes are unaffected.
5. Related work One approach to the problem of EDF scheduling of periodic tasks with deadlines smaller than periods is to repeatedly check the feasibility of a task set between point 0 and the first point at which the schedule repeats itself3. Early work by Baruah [Baruah,90] extended this basic idea by limiting and bounding the interval over which utilisation must be calculated. More recent work by Ripoll [Ripoll,95] has succeeded in further bounding this interval. In Ripoll’s work, resource utilisation is calculated either over the improved Baruah interval or over an 1
2 3
It seems that a fully optimal sequencing would require an non polynomial algorithm and is thus infeasible. This is also the case for optimal selection of harmonic sets. The use of sub-optimal heuristics, although not ideal, does enable significantly more jitter constrained threads to be accommodated than would be the case if harmonic sets were not considered. This overhead is a function of the particular mix of threads in the system and is thus likely to be quite variable. The overhead of the first scheme, in contrast, is independent of the thread mix. All static schedules for periodic tasks sets are inherently cyclic and repeat themselves over an interval of length equal to the lowest common factor of the individual periods of the tasks involved [Leung,80].
10
interval bounded by the initial critical interval (ICI), whichever is smaller. The ICI (which has to be recursively computed) is the interval between point 0 and the first point at which no outstanding computation exists. The tests used in this work are both necessary and sufficient. Their major drawback is that the worst case complexity is exponential (whereas our test (1) is polynomial) although it is claimed that the tests run pseudo-polynomially in the large majority of cases. Work by Jeffay [Jeffay,94] is targeted at reducing jitter and latency in end systems among multiple processes belonging to a single application. His approach is to regard the different tasks composing an application as a pipeline of co-operating processes and to make the structure of the application explicitly known to the kernel so it can optimise to reduce jitter and latency. In essence, this information is used to schedule the tasks forming the pipeline as if they were part of a single large sequential process. The limitation of this approach with respect to our test (2) is that it only works for tasks belonging to the same application. Furthemore, all the tasks involved must have the same period. Our scheme is considerably more general in that it allows delay and jitter to be reduced without requiring tasks to be related or to have identical periods. Another approach to the realisation of jitter constrained tasks is via the deadline monotonic algorithm first proposed in [Leung,82]. Like the rate monotonic algorithm, this assigns fixed priorities to tasks but according to deadlines rather than periods. In order to determine the schedulability of a task set it has to be checked if each task in the set can meet its deadline when it requires execution at the same time as all other tasks with a higher priority. In [Audsley,91] two different tests for deadline monotonic scheduling are introduced. The first considers, for each task, the worse case processing time that may be required by any higher priority task. This test is sufficient but not necessary in the general case. The second test, which is both sufficient and necessary, evaluates an offline schedule produced by the deadline monotonic scheduler to determine the exact interleaving of the higher priority processes; basically it is verified, for each task, that at any time between 0 and its deadline, the resource utilisation of all tasks with a higher or equal priority will be less than 1. It is not necessary to compute the utilisation at every instant in this interval due to inherent properties of periodic task sets. The first Audsley test takes an approach close to ours. However, because of the static priority assignment it is much more pessimistic in terms of resource utilisation than our EDF based test. Unlike our test (1), the complexity of the second test is dependent on the characteristics (i.e. period, deadline, execution time) of the tasks involved in addition to the number of tasks. In [Barth,94] rate monotonic scheduling is modified to accommodate delay and jitter sensitive tasks. Tasks with virtual rates higher than actual rates are introduced, and two different classes of tasks are considered: T1 contains tasks with virtual rates smaller than the real rates, and T2 contains tasks scheduled according to their real rates. Tasks are scheduled using the rate-monotonic scheduling algorithm; however, tasks of class T1 always have priority over tasks of class T 2. A drawback of the scheme is that priority inversion and deadline violations for tasks in T2 can occur. In contrast, our scheme gives predictable performance to all tasks. Finally, Han [Han,92] describes a method to schedule distance constrained task systems (DCTS); i.e. task systems where the distance between adjacent quanta of a periodic task is restricted. Han’s scheme works by transforming the given task set so that it can be described in terms of the pinwheel problem [Holte,89] and scheduled by offline pinwheel schedulers. In [Han,92] two algorithms are introduced to find a feasible schedule for the transformed DCTS problem. The derived density bound for these algorithms is the same as the utilisation bound for the rate-monotonic algorithm, i.e. 0.69. The drawback of this scheme, apart from the low utilisation bound, is that a completely new schedule has to be calculated each time a new task is introduced.
6. Conclusions and Future Work In this paper we have motivated the use of jitter constrained threads through a number of examples and have briefly indicated the applicability of these algorithms in the context of the
11
SUMO microkernel based distributed multimedia application support infrastructure. We have also presented schemes for the admission testing and run-time scheduling of such threads so that they perform predictably. Our test (1) is comparable with a number of other proposed schemes from the literature. The main difference is that, although it is sufficient but not necessary in the general case (it is both necessary and sufficient in the special case where deadlines are equal to periods), its complexity, which is polynomial, is simply dependent on the number of tasks to be scheduled rather than on the specific characteristics of the tasks themselves. Thus the test has an overhead which is both acceptably small and which scales predictably as new tasks are added. The fact that the test is not necessary in the general case is not a significant drawback in an environment such as SUMO where admission tested threads co-exist with non admission tested, best effort, threads. In addition, our test (2) goes beyond work reported in the literature by exploiting timing relationships between threads to considerably increase the number of threads schedulable. The current status of our work is that we have validated our scheme empirically through a pilot implementation of the admission tests together with an EDF simulator. At the present time we are implementing test (2), together with an associated run-time scheme, in the context of the SUMO system. A key issue in this implementation is the coexistence of threads with different commitment levels. This requires more than the simple run-time scheuler scheme outlined in section 4.2. There are three important areas of future work required to further develop our scheme. Firstly, there are the issues related to the optimal choice of harmonic sets and the sequencing heuristic to apply among harmonic set members. Second, we would like to extend our scheme to accomodate the case of variable processing times of different quanta of the same thread. Although the worse case execution time must be used where such variation is random, an approach where the thread is split into multiple ‘vitual’ threads is possible where the variation is regular and predictable. Finally, an interface is required that lets applications communicate inter-thread timing relationship to the scheduler. This interface would be used by applications to notify the scheduler of timing relationships among thread sets which are not members of a harmonic set (cf. the MPEG scenario of section 3.5.1). It may also be used to support negotiation with the application to help recognise harmonic sets in consultation with the application. The interface must be sufficiently general to allow the run-time scheduler to efficiently update the scheduling times of threads with arbitrary timing relationships while being simple and intuitive for use by applications.
12
Acknowledgement The work described in the paper was carried out in the context of the France Telecom funded SUMO project at Lancaster University, UK and CNET, France. We would like to thank France Telecom for their generous support.
13
References [Audsley,91] Audsley, N. C., Burns, A., Richardson, M. F.,and A. J. Wellings, “Hard-Real-Time Scheduling: The Deadline-Monotonic Approach”, Proc. 8th IEEE Workshop on Real-Time Operating Systems and Software, Atlanta, GA, USA, 1991. [Barth,94] Barth, I, “Extending the Rate-Monotonic Scheduling Algortihm to Get Shorter Delays”, Proc. 2nd International IWACA Workshop (IWACA '94), pp 104-114, Heidelberg, Germany, September 1994. [Baruah,90] Baruah, S., Mok, A., and L. Rosier, “Preemtively Scheduling Hard-RealTime Sporadic Tasks on One Processor”, Proc. 11th Real-Time Systems Symposium, Lake Buena Vista, 1990. [Bricker,91] Bricker, A., Gien, M., Guillemont, M., Lipkis, J., Orr, D., and M. Rozier, “Architectural Issues in Microkernel-based Operating Systems: the Chorus Experience”, Computer Communications, Vol 14, No 6, pp 347-357, July 1991. [Coulson,95] Coulson, G., Campbell, A., Robin, P., Blair, G.S., Papathomas, M. and D. Hutchison, “The Design of a QoS Controlled ATM Based Communications System in Chorus”, IEEE Journal on Selected Areas In Communications, Special Issue on ATM Local Area Networks, Vol 33, No 4, pp 686-699, May 1995. [Govindan,91] Govindan, R., and D.P. Anderson, “Scheduling and IPC Mechanisms for Continuous Media”, Proc 13th ACM Symposium on Operating Systems Principles, Asilomar Conference Center, Pacific Grove, California, USA, SIGOPS, Vol 25, pp 68-80, 1991. [Han,92] Han, C.C., and K.J. Lin, “Scheduling Distance-Constrained Real-Time Tasks”, Proc. 13th IEEE Real-Time System Symposium, pp 300-308, Phoenix, Arizona, 1992. [Holte,89] Holte, R., Mok, A., and L. Rosier, “The Pinwheel: A Real-Time Scheduling Problem”, Proc. 22nd Hawaii International Conference on System Science, Hawaii, 1989. [Jeffay,94] Jeffay, K.,“On Latency Management in Time-Shared Operating Systems”, Proc. 11th IEEE Workshop on Real-Time Operating Systems and Software, Seattle, pp 86-90, 1994. [Kuo,91] Kuo, T.W. and A.K. Mok, Load Adjustment in Adaptive Real-Time Systems", Proc. 12th IEEE Real Time System Symposium, pp 160-170, San Antonio, 1991. [Leung,80] Leung, J., and M. Merrill, “A Note on the Preemptive Scheduling of Periodic Real-Time Tasks”, Information Processing Letters, No 11, No 3, pp 115-118, 1980. [Leung,82] Leung, J. Y.T, and J. Whitehead, “On the Complexity of Fixed-Priority Scheduling of Periodic Real-Time Tasks”, Performance Evaluation 2, pp 237-350, 1982. [Liu,73] Liu, C.L. and J.W. Layland, “Scheduling Algorithms for Multiprogramming in a Hard Real-time Environment”, Journal of the Association for Computing Machinery, Vol 20, No 1, pp 46-61, February 1973. [Mauthe,92] Mauthe, A., Schultz, W. and R. Steinmetz, “Inside the Heidelberg Multimedia Operating System Support: Real-Time Processing of Continuous Media in OS/2, Technical Report No. 43.9214, IBM European Networking Center, Heidelberg, 1992. [Nieh,93] Nieh, J. and J.G. Hanko, “SVR4 UNIX Scheduler Unacceptable for Multimedia Applications”, Proc. Fourth International Workshop on Network and Operating System Support for Digital Audio and Video, pp 41-53, Lancaster, UK, Springer Verlag, October 93. [Ripoll,95] Ripoll, I., Crespo, A., Mok, A.K., and J. Echagüe, “Improvement in
14
Feasibility Testing For Real-Time Tasks”, Technical Report of Departamento de Ingenieria de Sistemas Computadores y Automatica, Universidad Politecnica de Valencia, Spain, 1995. [Steinmetz,94] R. Steinmetz, “Data Compression in Multimedia Systems: A Survey”, ACM Multimedia Systems Journal, Vol 1 No 5, March 1994. [Steinmetz,95] R. Steinmetz, “Multimedia File Systems Survey: Approaches for Continuous Media Disk Scheduling”,Computer Communications, Butterworth-Heinemann, Vol 18, No 3, March 1995. [Yeadon,94] Yeadon, N., Garcia, F., Campbell, A. and D. Hutchison, “QoS Adaptation and Flow filtering in ATM Networks”, Proc. 2nd International IWACA Workshop (IWACA '94), pp 191-202, Heidelberg, Germany, September 1994.
15
Appendix 1 Theorem A task set can be scheduled by EDF if ∀Ci ∈ C1 , ..., Cmax
k
∑ etime( j,
di ) di ≤ 1
j =1
e j , if t ≥ p j t p j + d j etime( j, t) = e j t p j + e j (t − p j t p j ), otherwise dj where C1 , ..., Cmax is a sequence of deadline equivalence classes arranged in ascending order of deadline and di is the deadline of deadline equivalence class Ci. 1..k ranges over all tasks in deadline classes C1 to Ci. Proof EDF is an optimal dynamic algorithm, i.e. it will always find a valid schedule whenever one exists. A valid schedule exists as long as the resource is not over-utilised. The resource is overutilised if a task j cannot gain access to the resource for at least ej time units from the time it becomes ready to the end of its deadline dj. Hence it is sufficient to prove that the resource will never be overutlised by task sets which are passed by the above formula in no matter what order they occure at run-time. In the following we take an inductive approach to the proof. A1.1 Deadline Equivalence Class C 1 For deadline equivalence class C 1 the etime formula is computed only over tasks with deadline d1 which is the smallest deadline of any task. Since we assume that deadlines are always ≤ periods, a maximum of one quantum of each task in C1 can appear in any interval of length d1. Therefore it is only necessary to show that the sum of all the execution times of the tasks in C1 is ≤ d1. For tasks whose deadline is equal to their period, the execution time is calculated in the first term of etime. For tasks with deadline ≤ period, the execution time is calculated in the top condition of the second term. Hence the execution times of all tasks in C1 are considered by the formula which correctly determines whether or not the necessary conditions for schedulability are met in this case. A1.2 Deadline Equivalence Class C i Now we have to show that, given a task set that is accepted by our formula, and given that the resource is not overutilised by any task in deadline equivalence classes C 1 to C i-1, the addition of tasks in deadline class Ci will still not overutilise the resource. As in the above case, for all tasks in C i, the execution time is considered either in the first term of etime if their deadline is equal to their period, or in the top condition of the second term if their deadline ≤ period. In either case, a maximum of one quantum of each task in Ci is considered for the same reason as stated above. Although at this point we have taken into account the execution times of all tasks in Ci, it remains to show that these tasks in combination with the tasks in classes C1 to Ci-1 will not overutilise the resource. To show this, we distinguish the two possible cases (detailed below) and show that the resource cannot be overutilised in either of these cases as long as the formula holds. A1.2.1 Case 1 All tasks in deadline equivalence classes C1 to Ci become ready for processing at the same 16
time. We observe that the maximum number of full periods to fit into an interval of length di from all tasks in C1to Ci-1, is
∑ d
i ∀j ∈C1 to Ci−1
pj
There will be exactly one quantum to consider for each of these periods, the execution times of which are considered in the first term of etime. But it is also necessary to consider execution times resulting from tasks that have additional partial periods that fit in between the end of their last full period and the end of di . If the deadline of the task is ≤ the length of this partial period, the execution time of a whole additional quantum must be added in. This is covered in the top condition of the second term of the formula1. Hence it can be seen that for the case where all tasks become ready at the same time, all possible quanta which have a deadline within d i are considered by the formula and no overutilisation can occur within di . Before we consider case 2 we must prove an auxilliary lemma: during a time interval z there cannot occur more than z p j deadlines associated with a task j, dj ≤ pj ≤ z. Proof Let kj = pj - dj. The interval z can be divided into two portions: i) an interval of length z p j p j and ii) a remainder R, R < d j + k j. The proof is by contradiction: if we
assume that there are more than z p j deadlines of task j within z, say z p j +1 deadlines, then there has to be one deadline before the start of the first period that occurs in z. Assuming further that the first deadline in z is right at the start of z, there must be at least kj ≥ 0 time units between this deadline and the start of the first period within z. There are a maximum of z p j full periods within z. Therefore in our assumed case we have z p j +1 deadlines, and z − ( z p j p j + k j ) time is left at the end of z . Since z = R + z p j p j , we have
R + z p j p j − ( z p j p j + k j ) = R − k j time is left. Using this and the fact that R < dj - kj, we deduce that R - kj < dj. Thus, there cannot be another deadline at the end of z and therefore there can not be more than z p j deadlines in z. A1.2.2 Case 2 A task in class Ci becomes ready for processing when some other task (in any class from C1 to Ci) is currently executing. To begin with, tasks in Ci will only occur once within di, and hence never require more processing time than is allocated for one quantum. Hence there cannot be any overutilisation caused by these tasks. For tasks in classes C1 to Ci-1 the interrupted task can have more than one quantum within 1
In addition to these quanta, there may also be quanta resulting from partial periods that overlap the end of di. However these cannot affect the execution of tasks within di because their deadline is after di and therefore they will not be scheduled in preference to any other task with a deadline ≤ di. Nevertheless it must be ensured that no overutilisation will occur after d i as a result of such quanta. Therefore an appropriate proportion of the resource required by these quanta has to be considered within di. This is allowed for in the bottom condition of the second term.
17
di. It remains to show that the resource is not overutilised because the currently executing task (call it k) requests more resource than is considered by our formula. In the following, assume that k has finished an amount t of its processing time and thus ek t of its first quantum is still outstanding. According to the above lemma the maximum number of deadlines of task k is di pk . Hence the maximum amount of processing time required for
task k within di is ek − t + di pk ek .
If di ≥ pk di pk + dk the amount of resource reserved for task k is di pk ek . So in this case k cannot overutilise the resource. It remains to show that no overutilisation occurs when di < pk di pk + dk . If ek − t + ( pk − dk ) ≤ di − ( pk di pk , then task k has di pk deadlines within di and an overall processing time requirement of ek − t + di pk ek . Now, the amount of processing time e allowed for task k in our formula is ek di pk + k (di − pk di pk ). Assume dk ek − t > ek dk (di − di pk ). In this case there is the potential for an overflow if all other tasks require the maximum amount of resource considered in the formula. Any overflow can only occur at the end of d i because (as we have already established) there is no overflow for deadline classes C1 to Ci-1. If overflow occurs, a task with deadline di, or one of deadline class C1 to Ci-1 when its deadline coincides with the end of di, will miss its deadline. According to [Liu,73] there is no processor idle time prior to an overflow, i.e. the resource is always busy throughout di. If the processor was idle within di, task j could be processed and finished to its deadline. If, in this situation, task k requires more than ek dk (di − di pk ) in di, this must be because it did not have its allocated share of the resource prior to di. Further, there must have been one or more tasks with an earlier deadline delaying the processing of task k. But, since there can have been no idle time before the processing of these tasks as well, the processor must have been fully utilised between a certain time, say z, and the end of di. As we showed in case 1 (where all tasks in deadline classes C1 to Ci-all get ready at the same time) z cannot be positioned at the start of di. Furthermore, z cannot be positioned anywhere else either because this would imply that the overutilisation is caused by tasks from deadline classes from C1 to Ci1. The conclusion, therefore, is that z cannot exist and thus we have shown (by contradiction) that no overutilisation takes place.
18
Appendix 2 This appendix presents in detail the formulae required in section 3.4.2 to evaluate the processing times of harmonic sets of length d1 and starting at the beginning of active spans (the set ES ) and finishing at the end of active spans (the set ED). A2.1 The Set E S : Intervals Starting at the Start of Active Spans In evaluating the processing time requirement of a harmonic set over intervals of di that begin at the start of an active span, the first such starting point is the nominal point 0 (refer to figure 5) and the last is at: pH p − 1 pL L where pH is the period of the thread with the longest period in the harmonic set H and pL is the period of the thread with the shortest period in H 1. In figure 5, the last starting point is point G which is calculated as 16/4 - 1 * 4 = 12. It is not necessary to look beyond this point as the timing pattern of the harmonic set merely repeats itself. In general, the set of all starting points of active spans of all threads in a group H is given by: p S = soffset( j), p j + soffset( j), 2 p j + soffset( j), ... , H − 1 p j + soffset( j), ∀j ∈ H pj j −1
where soffset( j) = ∑ dk k =1
The shown sequence corresponds to the starting times of active spans of a particular thread j. The set as a whole contains all the starting times of all the threads in the harmonic set. The soffset function corrects for the initial offset from point 0 for thread j: i.e. the sum of the deadlines of all threads with an earlier deadline than j. For example, the fixed offset of thread t3 in figure 5 is 2 + 3 = 5. Having derived the set S of starting times of active spans in H, we now need to calculate the processing time requirement of the harmonic set over an interval of length dc that starts at some particular instant S i in the set S. Let us first, however, evaluate the processing time requirement of a single thread j in such an interval. To do this, we first consider all the processing time that j requires in specific interval: 0 .. I j
p where I j = H − 1 p j + dc pj
Using the etime function from formula (2), this is simply etime(j, Ij). Now we can express the processing time requirement of j over an interval of length dc starting at Si in terms of Ij: E j,Si
(
= (etime( j, I j ) − etime( j, I j,1 )) − etime( j, I j ) − etime( j, I j,2 )
)
= etime( j, I j,2 ) − etime( j, I j,1 )
1
This assumes that the harmonic set members are sequentially arranged such that the scheduling time of one thread is the deadline of another.
19
Si − soffset( j), if Si > soffset( j) where I j,1 = 0, otherwise Si + dc − soffset( j), if Si + dc > soffset( j) I j,2 = 0, otherwise Here, Ij,1 is the interval between the start of the first active span of thread j and point Si, and Ij,2 is the interval between the start of the first active span of thread j and point Si + dc. By subtracting the processing time requirement over Ij,1 from Ij and subtracting the result from Ij minus Ij,2, we obtain the processing time requirement for the required interval. The soffset functions in Ij,1 and Ij,2 represent a correction factor representing the fixed offset between the nominal point 0 and the first occurrence of an active span of thread j. Note that if Ij,1 or Ij,2 work out at less than zero, they are set to zero as it makes no sense to calculate a resource usage over a negative interval. Finally, having calculated the processing time used by thread j over the interval dc starting at time Si, we can derive the total amount of processing time used by all members of H with a deadline ≤ dc and starting at Si, by means of a simple summation. We refer to this quantity as E S. H
(
ES = ∑ etime( j, I j,2 ) − etime( j, I j,1 ) j =1
)
A2.2 The Set E D : Intervals Ending at the End of Active Spans We adopt a similar strategy to derive the total amount of processing time used by all members of H with a deadline ≤ dc and working backwards in time from the end of an active span. First, we derive a set D which is analogous to the set S but contains the set of end points of active spans (i.e. deadlines). p D = doffset( j), p j + doffset( j), 2 p j + doffset( j), ... , H − 1 p j + doffset( j), ∀j ∈ H pj j
where doffset( j) = ∑ dk k =1
The function doffset is similar to soffset with the difference that it returns the offset of the deadline of thread j rather than the start. Having derived the set D, we now derive a quantity Ej,Di which, by analogy to Ej,Si above, represents the processing time requirement for thread j in the interval dc working back from time Di. p d E j, Di = etime( j, I j,3 ) − etime( j, I j,4 ) + e j H c − etime( j, I j,5 ) p j p j Di − soffset( j), if Di > soffset( j) where I j,3 = 0, otherwise Di − dc − soffset( j), if Di > dc + soffset( j) I j,4 = 0, otherwise
20
I j,5
dc pH − ( dc − Di + soffset( j)), if Di < dc pH = dc pH p , otherwise H
Intuitively, Ij,3 is the interval between the start of the first active span of thread j and the current Di; Ij,4 is the interval between the start of the first active span of thread j and the point Di -dc; Ij,5 represents the amount by which dc reaches back into previous periods. As with Ij,1 and Ij,2, soffset is used as a correction factor representing the fixed offset between the nominal point 0 and the first occurrence of an active span of thread j. Thus, the formula to express E D , the total amount of processing time required by all members of H with a deadline ≤ dc and working backwards from the end of a active span, is: H p d ED = ∑ etime( j, ti,3 ) − etime( j, ti,4 ) + e j H c − etime( j, ti,5 ) p j pH j =1
21