Multiprocessor Scheduling of Age Constraint Processes Lars Lundberg Department of Computer Science, University of Karlskrona/Ronneby, Soft Center, S-372 25 Ronneby, Sweden, email: Lars.Lundberg@ide.hk-r.se Abstract Real-time systems often consist of a number of independent processes which operate under an age constraint. In such systems, the maximum time from the start of process L i in cycle k to the end in cycle k+1 must not exceed the age constraint A i for that process. Multiprocessors provide a scalable and cost-effective way of meeting the performance demands of such systems. The age constraint can be met using fixed priority scheduling and periods equal to A i /2. However, this approach restricts the number of process sets which are schedulable. In this paper, we define a method for obtaining process periods other than A i /2. The periods are calculated in such a way that the age constraints are met. Our approach is better in the sense that a larger number of process sets can be scheduled compared to using periods equal to A i /2. 1 Introduction Real-time systems often consist of a number of independent periodic processes. These processes may monitor sensors or database variables. When these variables or sensors change, the system have to produce certain outputs within certain time intervals. These outputs must be calculated from input values which are fresh, i.e. the age of the input value must not exceed certain limits. The processes in such systems operate under the age constraint. Multiprocessing is a cost-effective and scalable way of meeting the performance demands of such systems. The age constraint defines a limit on the maximum time from the point in time when a new input value appears to the point in time when the appropriate output is produced. Figure 1 shows a scenario where a value E i appears shortly after process L i has started its k:th cycle (denoted L k i). Process L i starts its execution by reading the sensor or variable. Consequently, E i will not affect the output in cycle k. The output F i corresponding to value E i (or fresher) is produced at the end of cycle k+1. The age constraint A i is defined as the maximum time from the beginning of the process' execution in cycle k to the end of the process' execution in cycle k+1. A scheduling scheme can be either static or dynamic. In dynamic schemes the priority of a process may vary at run-time, e.g. the earliest deadline algorithm [3]. In static schemes, processes are assigned a fixed priority, e.g. the rate-monotone algorithm [5]. Fixed priority scheduling is relatively easy to implement and requires less overhead than dynamic schemes. Most studies in this area have looked at scenarios where the period of a process is known. However, for age constraint processes the period is not known. We have instead defined a maximum time between the beginning of the process' execution in cycle k to the end of the process' execution in cycle k+1. We would like to translate this restriction into a period for the process thus making it possible to use fixed priority schemes. The age constraint is met by specifying a process period T i ' = A i /2 (we will use the notation T i for other purposes), thus obtaining a set of processes with known periods T i ' and computation times C i. For such scenarios, it is well known that rate-monotone scheduling is optimal, and a number of schedulability tests have been obtained [5]. Specifying a process period T i ' = A i /2 for age constraint processes is, however, an unnecessary strong restriction, which do not allow that the start of L i in cycle k and the end in cycle k+2 may be separated by a time greater than 3T i ', whereas the age constraint allows a separation of up to 2A i - C i = 4T i ' - C i. We have previously defined periods which make it possible to schedule a larger number of process sets than using T i ' = A i /2 [6]. The previous result did, however, only consider single-processors. In this paper we also consider multiprocessors.
C i A i T i T i L k i L k + 1 i E i changes time F i is produced Figure 1: The age constraint for process L i. The rest of this paper is structured in the following way. Section 2 contains the definition of the scheduling problem. Section 3 describes the technique for calculating the process periods. In section 4 we investigate an improved version of our scheduling scheme. Section 5 contains the discussion and conclusions. At the end there is an appendix. 2 Problem definition Consider a set of n processes L = [L 1,L 2,...,L n ], with associated age constraints A i and computation times C i. The priority of each process is defined by its age constraint A i. The smaller the value A i, the higher the priority of L i, i.e. the priority order is the same as for rate-monotone scheduling with T i = A i /2. We order the processes in such a way that A i A i+1. Consider also a multiprocessor with m identical processors. The processes may be executed by any processor. The multiprocessor uses preemptive scheduling, and a process which has been preempted may later resume execution on another processor than the one it was executing on before it was preempted. When a process L i has completed its k:th cycle L i becomes sleeping until it is released at the start of cycle k+1. L i becomes active when it is released. As long as L i has not completed its execution in cycle k+1, and there are less than m active processes with higher priority, L i will be executed by one of the processors. However, during the time periods when there are at least m active proc- L 1 1 L 1 3 L 3 1 L 1 12 L 2 1 L 2 2 Process L 1 and L 2 are never interrupted by any other process when using a multiprocessor with two processors, i.e. R 1 = C 1 = 2 and R 2 = C 2 = 2.5. From this graph we see that R 3 = 5. In this graph we release L 2 at time 1.25. All other processes are released at time zero. This results in a response time for L 4 of 6.75. which is the worst-case scenario. Consequently, R 4 = 6.75 (see appendix A). 0 2 4 6 8 10 12 Time Figure 2: Calculating the maximum response times for a set with four processes L 1, L 2, L 3, and L 4 (T 1 = 4, C 1 = 2, T 2 = 9, C 2 = 2.5, T 3 = 15, C 3 = 3, T 4 = 20, and C 4 = 3) when using a multiprocessor with two processors. The upper graph shows how R 3 can be calculated when T 1, C 1, T 2, C 2, and C 3 are known. The lower graph shows how R 4 can be calculated when T 1, C 1, T 2, C 2, T 3, C 3 and C 4 are known. This example shows that it is possible to calculate R i if the periods and computation times of all processes with higher priority than L i are known. However, since the problem of finding minimal response times is NP-hard we will use a pessimistic estimate which gives R 4 = 7.75 (see appendix A).
esses with higher priority than L i, the process has to wait. When L i has completed cycle k+1 it becomes sleeping until it is released at the start of cycle k+2, and so on. The maximum response time R i of L i is the maximum time from the release of L i in a cycle to the time that L i completes in that cycle. If the execution of L i is never interrupted by any other process, R i is equal to C i. However, for low priority processes the execution may be interrupted by processes with higher priority. Using the standard problem formulation, where processes are defined by their periods T i ' and computation times C i, a set of n processes is schedulable if R i T i '(1 i n) [3]. Previous results show that a set of age constraint processes is schedulable if R i A i /2 (1 i n) [5]. + i 1 It is well known that R i = C i R i T j C j [3] for single-processors, i.e. R i depends on the periods of the processes with higher priority than L i. For multiprocessors the situation becomes more complicated. However, R i still depends on the periods of the processes with higher priority than L i. At first glance, one might think that the maximum response time is obtained when all processes are released at the same time. This is, however, not always the case for multiprocessors (see appendix A). The procedure for obtaining R i is presented in appendix A. As discussed in appendix A, it is NP-hard [4] to obtain R i for i > m+1. Therefore, a pessimistic estimate on R i is used. This estimate is obtained from the formula i 1 R i = C i + ( R i T j C j ) m (see appendix A). We want to obtain process periods T i, which make it possible to schedule a larger number of process sets than using the periods T i ' = A i /2. Before we look at how these periods are calculated we consider the following lemma: Lemma: Consider a set of n processes with periods T i and computation times C i. If we extend a period for process i, then the maximum response time for process j does not increase (1 i j n) when using a multiprocessor with m processors. Proof: We obtain R i from the formula R i = C i + i 1 ( R i T j C j ) m (see appendix A). Obviously, the R i that solves this equation does not increase when T i increases. 3 Calculating process periods In order to calculate the periods T = [T 1,T 2,...,T n ] we start by considering L 1,...,L m. These processes have the highest priorities, and will not be interrupted by any other process, using m processors. According to the Lemma above, we want to select as long periods as possible, thus minimizing the response time for processes with lower priorities. Obviously, T i must not exceed A i -C i. Since L 1,...,L m have the highest priorities, it is safe to set the periods to T 1 = A 1 -C 1,...,T m = A m -C m. We now consider L m+1. From appendix A we see that R m+1 can be obtained when T 1,...,T m have been fixed. We want to select as long periods as possible, thus minimizing the response time for processes with lower priorities, i.e. T m+1 = A m+1 -R m+1. Now, R m+2 can be obtained since the periods T 1,...,T m+1 have been fixed, i.e. R m+2 = L 1 L 3 L 2 L 4 Time 0 2 4 6 8 10 12 14 16 Figure 3: A multiprocessor with two processors, and four processes L 1, L 2, L 3, and L 4 defined by A 1 = 6, C 1 = 2, A 2 = 8.5, C 2 = 2.5, A 3 = 12, C 3 = 3, A 4 = 17.75, and C 4 = 3. From this we get T 1 = A 1 - C 1 = 4 (R 1 = 2 A 1 /2 = 3) and T 2 = A 2 - C 2 = 6 (R 2 = 2.5 A 2 /2 = 4.25). By using the method in appendix A we first calculate T 3 = 9 (R 3 = 5 A 3 /2 = 6) and then T 4 = 10 (R 4 = 7.75 A 4 /2 = 8.875). The first release is done at time zero for all processes. The figure shows four cycles of process L 1, three cycles of L 2, two cycles of L 3, and two cycles of L 4.
m + 1 C m+2 + ( R m + 2 T j C j ) m. When R m+2 has been obtain we get T m+2, i.e. T m+2 = A m+2 -R m+2, and so on. Theorem 1: A process set which is schedulable using rate-monotone priority assignment, T i = A i /2 and a single-processor (m = 1) is also schedulable using our scheme. Proof: (see [5]) Theorem 2: A process set which is schedulable using rate-monotone priority assignment, T i = A i /2 and a multiprocessor with m processors is also schedulable using our scheme, provided that we use the same schedulability test. Proof: From previous results on age constraint processes we know that a set of n processes is schedulable if R i A i /2 (1 i n) [5]. As discussed in appendix A, it is NP-hard to calculate the maximum response time. Therefore, we use the pessimistic estimate R i = C i + i 1 ( R i T j C j ) m. The schedulability test is based on this pessimistic estimate on R i, and may therefore also be pessimistic, i.e. there may be schedulable process sets which do not meet this schedulability test. However, due to the NP-hard nature of the problem it is reasonable to use the same schedulability test for the case with our periods and for the case with periods equal to half the age constraint. We consider a set of processes which is schedulable using rate-monotone priority assignment and T i = A i /2. Consequently, R i T i = A i /2. From this it follows that T i = A i /2 T i = A i - R i. From the Lemma in the previous section we know that, using a multiprocessor with m processors, the maximum response time for process j does not increase if we extend the period for process i (1 i j n). Consider the process set in figure 3, which is schedulable using our scheme. If we would have used the periods A i /2, we would have got T 1 = 3, T 2 = 4.25, T 3 = 6, and T 3 = 8.875. This would have resulted in a utilization of C 1 /T 1 + C 2 /T 2 + C 3 /T 3 + C 4 /T 4 = 2/3 + 2.5/4.25 + 3/6 + 3/8.875 = 2.093 > 2, i.e. the set would not have been schedulable on a two processor multiprocessor. 4 Improving the scheme Let R(j) j+x (x > 0) denote the response time for L j+x if L j is released at time -C j, and L j+x is released at time zero. The release of all other processes is arbitrary. The idea is that if T j+x = kt j (for some integer k > 0), we can adjust the phasing of L j and L j+x in such a way that the interference of L j on L j+x is limited to R(j) j+x. Consequently, if T j+x < kt j T j+x + R j+x - R(j) j+x we can extend the period of L j+x to kt j and adjust the phasing of L j and L j+x in such a way that a release of L j+x always occurs C j time units after a release of L j. In order to distinguish the optimized periods from the ones obtained using the unoptimized version, we denote the optimized period for L j as t j. Using the same argument as before (see appendix A), we obtain R(j) j+x from the formula R j+x = C i + j x 1 + R j x R ----------- j+ x C T + + T j + C j R l ----------------------------------- j+ x ----------- l T l = 1 j T Cj j -------------------------------------------------------------------------------------------------------------------------- m In order to obtain the optimized periods t j, for a set containing n processes, we start with the periods T j and we then use the following algorithm: for y = 1 to n loop t y = T y for to y-1 loop if t y < kt j T y + R y - R(j) y then t y = kt j and exit inner loop (L y will be released C j time units after L j ) end loop end loop Theorem 3: A set of processes which is schedulable using the unoptimized periods T i and an arbitrary phasing of processes is also schedulable using the optimized periods t i, provided that we are able to adjust the phasing. Proof: Let r i denote the maximum response time for process L i using the periods t i and the optimized phasing. Obviously, T i t i. From this and the Lemma we conclude that r i R i. Consequently, if R i A i /2, then r i A i /2.
5 Conclusions and discussion A method for scheduling age constraint processes on a multiprocessor has been presented. An age constraint process is defined by two values: the maximum time between the beginning of the process execution in cycle k to the end of the process execution in cycle k+1 (the age constraint), and the maximum computation time in each cycle, i.e. the period is not explicitly defined. We have presented a method for calculating process periods. The method takes the number of processors in the multiprocessor, the age constraint and the computation time for each process as inputs. Based on these inputs it calculates a period for each process, i.e. we may get different periods depending on the number of processors in the target multiprocessor. The method can be implemented as a computer program, and is thus completely automatic. Once the periods have been calculated the process set can be executed using preemption and fixed priority scheduling. The priorities are defined by the rate-monotone algorithm, i.e. processes with tight age constraints get high priorities. Trivially, the age constraint can be met by using periods equal to half the age constraint. In that case, rate monotone scheduling is optimal [5]. In our scheme, the period of a process depends on the priority of the process (and on the number of processors in the multiprocessor). The period for a process L i gets shorter if the priority of L i is reduced and vice versa. This property makes our scheme hard to analyze, e.g. show optimality. However, the periods obtained from our method are better in the sense that, using a single-processor, they make it possible to schedule a larger number of process sets compared to using periods equal to half the age constraint (see Theorem 1). This is true also for multiprocessors, provided that we use the same schedulability test (see Theorem 2). We have also shown that there are process sets that are schedulable using our scheme which can not be scheduled using periods equal to half the age constraint. We also define an improved version of our method. The improved version capitalizes on the fact that there is room for optimization when the period of one process is an integer multiple of the period of another process. The improved version is better than the original version in the sense that, we are able to schedule a larger number of process sets (see Theorem 3). A difficult part of the method is the calculation of the maximum response times (see appendix A). This is also one of the areas where we plan to focus our future efforts. Currently, we are using a pessimistic estimate of the maximum response time which is very easy to calculate (see appendix A). Previous work on age constraint process have concentrated on creating cyclic interleavings of processes [1]. Other studies have looked at age constraint processes which communicate [8]. One such scenario is scheduling of age constraint processes in the context of hard realtime database systems [2]. Fixed priority scheduling of age constraint processes on single-processors has been studied previously [6]. References [1] W. Albrecht, and R. Wisser, "Schedulers for Age Constraint Tasks and Their Performance Evaluation", In Proceedings of the Third International Euro-Par Conference, Passau, Germany, August 1997. [2] N. C. Audsley, A. Burns, M.F. Richardson, and A.J. Wellings, "Absolute and Relative Temporal Constraints in Hard Real-Time Databases", In Proceedings of IEEE Euromicro Workshop on Real-Time Systems, Los Alamitos, California, February 1992. [3] A. Burns, and A. Wellings, "Real-Time Systems and Programming Languages", Addison-Wesley, 1996. [4] M. Garey, and D. Johnson, "Computers and Intractability", W.H. Freeman and Company, 1979. [5] J.P. Lehoczky, L. Sha, and Y. Ding, "The rate monotone scheduling algorithm: exact characterization and average case behavior", In Proceedings of IEEE 10th Real-Time Systems Symposium, December 1989. [6] L. Lundberg, "Fixed Priority Scheduling of Age Constraint Processes", In Proceedings of the Fourth International Euro-Par Conference, Southampton, England, September 1998. [7] M. Pinedo, "Scheduling: Theory, Algorithms and Systems", Prentice Hall, 1995. [8] X. Song, and J. Liu, "How Well can Data Temporal Consistency be Maintained", In Proceedings of the 1992 IEEE Symposium on Computer Aided Control Systems Design, Napa, California, USA, March 1992.
Appendix A: Calculating the maximum response time It is trivial to calculate the maximum response time R i for processes L 1 to L m. In these cases the R i = C i. The reason for this is that the processes L 1 to L m will never be blocked waiting for a process with higher priority when using a multiprocessor with m processors. It is also trivial to calculated the maximum response time for process L m+1. R m+1 is obtained when all processes are released at time zero. However, calculating R i in general is more complicated. Consider the small example in figure A.1 shows that the maximum response time is not always obtained when all processes are released at time zero. Finding the release times which results in the maximum response time is an NP-hard problem [4]. A number of cases can probably be sorted out using branch-and-bound techniques [7]. However, due to the NP-hard nature of the problem, we use the observation that the maximum response R i time for L i cannot exceed + i 1 C i ( R i T j C j ) m [3]. If we apply the equation R i = C i i 1 ( R i T j C j ) m to L 4 (R 1, R 2, and R 3 are trivial) in figure A.1, we get R 4 = 3 + ( R 4 T 1 C 1 + R 4 T 2 C 2 + R 4 T 3 C 3 )/2 = 3 + ( R 4 4 2 + R 4 9 2.5 + R 4 15 3)/2 => 7.75 = 3 + ( 7.75 4 2 + 7.75 9 2.5 + 7.75 15 3)/2 = 3 + (2*2+2.5+3)/2 = 3+4.75 = 7.75. Consequently, this method would lead to an estimate of 7.75 on R 4, which is more than 6.75 (which is the correct value). This example shows that the result of the equation may in some cases be pessimistic, i.e. the response time obtained from this equation may in some cases exceed the maximum response time. L 1 1 L 1 3 L 3 1 L 1 12 L 2 1 L 2 2 Process L 1 and L 2 are never interrupted by any other process when using a multiprocessor with two processors, i.e. R 1 = C 1 = 2 and R 2 = C 2 = 2.5. From this graph we see that R 3 = 5. L 1 1 L 1 3 L 1 4 L 1 12 L 1 4 L 2 1 L 3 1 L 2 2 In this graph we added process L 4. All processes are released at time zero. This figure indicates that R 4 = 6.5. This is however not correct. In this graph we release L 2 at time 1.25. All other processes are released at time zero. This results in a response time for L 4 of 6.75. which is the worst-case scenario. Consequently, R 4 = 6.75. 0 2 4 6 Time 8 10 12 Figure A.1: Calculating the maximum response times for a set with four processes L 1, L 2, L 3, and L 4 (T 1 = 4, C 1 = 2, T 2 = 9, C 2 = 2.5, T 3 = 15, C 3 = 3, T 4 = 20, and C 4 = 3) when using a multiprocessor with two processors.