460 likes | 600 Views
Real-Time Systems, COSC-4301-01, Lecture 4. Stefan Andrei. Reminder of the last lecture. Sporadic tasks Scheduling nonpreemptable tasks Scheduling nonpreemptable sporadic tasks Scheduling nonpreemptable tasks with precedence constraints
E N D
Real-Time Systems, COSC-4301-01, Lecture 4 Stefan Andrei COSC-4301-01, Lecture 4
Reminder of the last lecture • Sporadic tasks • Scheduling nonpreemptable tasks • Scheduling nonpreemptable sporadic tasks • Scheduling nonpreemptable tasks with precedence constraints • Communicating periodic tasks: deterministic rendezvous model COSC-4301-01, Lecture 4
Overview of This Lecture • Multiprocessor scheduling • Available scheduling tools • Available real-time operating systems COSC-4301-01, Lecture 4
Multiprocessor scheduling • Generalizing the scheduling problem from a uniprocessor to a multiprocessor system increases the problem complexity since we now have to tackle the problem of assigning tasks to specific processors. • In fact, for two or more processors, no scheduling algorithm can be optimal without a priori knowledge of the: • Deadlines • Computation times • Start times of the tasks. COSC-4301-01, Lecture 4
Scheduling single-instance tasks • Given n identical processors and m tasks at time i, m > n, our objective is to ensure that all tasks complete their execution by their respective deadlines. • If m ≤ n (i.e., the number of tasks does not exceed the number of processors), the problem is trivial since each task has its own processor. COSC-4301-01, Lecture 4
Schedule representation • Static schedule representations: • Gantt charts • Timing diagrams • Dynamic schedule representations: • Scheduling game boards [Dertouzos, Mok; 1989] • Example of two-processor system (n=2) for three single-instance tasks: • J1: S1 = 0, c1 = 1, D1 = 2 • J2: S2 = 0, c2 = 2, D2 = 3 • J3: S3 = 0, c3 = 4, D3 = 4 COSC-4301-01, Lecture 4
A Gantt chart for Example of slide 5 • The below figure shows the Gantt chart of a feasible schedule for this task set. • Figure 3.23 from [Cheng; 2005], page 66 COSC-4301-01, Lecture 4
A timing diagram for Example of slide 5 • The below figure shows the timing diagram of a feasible schedule for this task set: • Figure 3.24 from [Cheng; 2005], page 67 COSC-4301-01, Lecture 4
A game board for Example of slide 5 • The below figure shows the scheduling game board representation of this task set at time i=0. • The x-axis shows the laxity of a task and the y-axis shows its remaining computation time. • Figure 3.25 from [Cheng; 2005], page 66 COSC-4301-01, Lecture 4
Scheduling single-instance tasks with game board • Let C(i) denote the remaining computation time of a task at time i, and let L(i) denote the laxity (slack) of a task at time i (i.e., L(i)=D(i)-C(i)-S(i)). • On the L-C plane of the scheduling board, executing any n of the m tasks in parallel corresponds to moving at most n of the m tokens one division (time unit) downward and parallel to the C-axis. • Thus, for tasks executed: • L(i+1) = L(i), C(i+1)=C(i)-1 • Tokens corresponding to the remaining tasks that are not executed move to the left toward the C-axis. • Thus, for tasks not executed: • L(i+1) = L(i)-1, C(i+1)=C(i) COSC-4301-01, Lecture 4
Rules for the Scheduling Game Board • Each configuration of tokens on the L-C plane represents the scheduling problem at a point in time. • The rules for the scheduling game are: • Initially, the starting L-C plane configuration with tokens representing the tasks to be scheduled is given. • At each step of the game, the scheduler can move at most n tokens one division downward toward the horizontal axis. • The rest of the tokens move leftward toward the vertical axis. • Any token reaching the horizontal axis can be ignored (it has completed its execution). • The scheduler fails if any token crosses the vertical axis into the second quadrant before reaching the horizontal axis. • The scheduler wins if no failure occurs. COSC-4301-01, Lecture 4
EDF scheduler fails (ex. From slide 5) • Example of two-processor system (n=2) for three single-instance tasks: • J1: S1 = 0, c1 = 1, D1 = 2 • J2: S2 = 0, c2 = 2, D2 = 3 • J3: S3 = 0, c3 = 4, D3 = 4 • J1 and J2 have earlier absolute deadline, so they are assigned to start. • Figure 3.26 from [Cheng; 2005], page 68 COSC-4301-01, Lecture 4
LL scheduler wins (ex. From slide 5) • At time 0, J3 has the lowest laxity, so it is assigned to start. • The other one can be J1 (since it has same laxity as J2). • Figure 3.27 from [Cheng; 2005], page 69 COSC-4301-01, Lecture 4
Conflict-Free Task Sets • For two or more processors, no deadline scheduling algorithm can be optimal without a priori knowledge of the deadlines, computations times, and start times of the tasks. • If no such a priori knowledge is available, optimal scheduling is possible if the set of tasks does not have subsets of conflict with each another [Dertouzos, Mok; 1989]. • A special case is that in which all tasks have unit computation times (then EDF algorithm is optimal even for the multiprocessor case). COSC-4301-01, Lecture 4
Conflict-Free Task Sets • We divide the scheduling game board in 3 regions: • R1(k)={Jj: Dj≤ k} • R2(k)={Jj: Lj≤ k and Dj > k} • R3(k)={Jj: Lj> k} • where k is the number time units. • Surplus computing power function: • F(k,i)=kn-ΣR1Cj-ΣR2(k-Lj), for every positive integer k. COSC-4301-01, Lecture 4
A Necessary Condition for Conflict-Free Task Sets • F(k,i) provides a measure of the surplus computing power of the multiprocessor system in terms of available processor time units between a given time instant i and k time units into the future. • A necessary condition for scheduling to meet the deadlines of a set of tasks whose start times are the same (at time i=0) is: • For all k>0, F(k,0) ≥ 0. COSC-4301-01, Lecture 4
A Sufficient Condition for Conflict-Free Task Sets • Schedulability test 9: • For a multiprocessor system, if a schedule exists that meets the deadlines of a set of single-instance tasks whose start times are the same, then the same set of tasks can be scheduled at run-time even if their start times are different and not known a priori. • Knowledge of pre-assigned deadlines and computation times alone is enough to schedule using LL-algorithm. COSC-4301-01, Lecture 4
Scheduling single-instance tasks. Example • Let us consider the following preemptable single-instance task set: • J1: S1 = 0, c1 = 1, D1 = 2 • J2: S2 = 0, c2 = 2, D2 = 4 • J3: S3 = 0, c3 = 4, D3 = 5 • how many processors do the above tasks set need to execute? • check the applicability of EDF-scheduling method. • draw a game board and check the applicability LL-scheduling method. • check the applicability of schedulability test 9. COSC-4301-01, Lecture 4
Scheduling single-instance tasks. Example • One processor does not suffice as at least one job will miss its deadline. • Hence, there is a need of 2 processors to execute the given task set. COSC-4301-01, Lecture 4
Scheduling game board. EDF strategy. Initial state COSC-4301-01, Lecture 4
Scheduling game board. Time t=1(EDF) • By EDF algorithm, J1 and J2 execute first since their absolute deadlines are earlier than J3. COSC-4301-01, Lecture 4
Scheduling game board. Time t=2(EDF) • Since J2 reaches horizontal axis, it is completed. COSC-4301-01, Lecture 4
Scheduling game board. Time t=5(EDF) • J2 completes its execution at time t=5. COSC-4301-01, Lecture 4
Scheduling game board. LL strategy. • To check whether LL strategy works, we consider the scheduling board at the initial state (slide 20). • At time t=0, both J1 and J3 have laxity 1. • Hence J1 and J3 move downward (vertically) and J2 moves to the left (horizontally). COSC-4301-01, Lecture 4
Scheduling game board. Time t=1 (LL) • At time t=1, J1 completes execution so the remaining tasks are J2 and J3. COSC-4301-01, Lecture 4
Scheduling game board. Time t=2 (LL) • At time t=2, J2 and J3 again move downward. COSC-4301-01, Lecture 4
Scheduling game board. Time t=3 (LL) COSC-4301-01, Lecture 4
Scheduling game board. Time t=4 (LL) COSC-4301-01, Lecture 4
Schedulability test 9 applied to our example • Since there is an LL schedule for the above task set, it means the task set can be scheduled at run-time even if their start times are different and not known a priori (using the LL-algorithm). COSC-4301-01, Lecture 4
Scheduling Periodic Tasks • LL scheduler is optimal for a set of single-instance tasks satisfying a sufficient condition. • This makes it possible to schedule tasks without knowing their release times in advance. • This LL scheduler is no longer optimal for periodic tasks. COSC-4301-01, Lecture 4
A Sufficient Condition for Scheduling Periodic Tasks • Schedulability test 10: • Given a set of k independent, preemptable (at discrete time instants), and periodic tasks on a multiprocessor system with n processors with U=c1/p1+…+ck/pk≤n, let • T=GCD(p1, …, pk), and t=GCD(T,T(c1/p1), …, T(ck/pk)). • A sufficient condition for feasible scheduling of this task set is t is integral. COSC-4301-01, Lecture 4
Scheduling Periodic Tasks. Example 1 • Consider two processors (n=2) and four tasks (period = deadline): • J1: c1=32, p1=40 • J2: c2=3, p2=10 • J3: c3=4, p3=20 • J4: c4=7, p4=10. • U=32/40+3/10+4/20+7/10=2 ≤ n • T=GCD(40, 10, 20, 10) = 10 • t=GCD(10, 10(32/40), 10(3/10), 10(4/20), 10(7/10)) = GCD(10, 8, 3, 2, 7)=1. • Since 1 is integral, a feasible schedule exists for this tasks set (according to Schedulability test 10). COSC-4301-01, Lecture 4
A Feasible Schedule for Example 1 • The tasks are assigned to processor 1 and “fill it up” until we encounter a task that cannot be scheduled on this processor. • Figure 3.28 from [Cheng; 2005], page 71 COSC-4301-01, Lecture 4
Scheduling Periodic Tasks. Example 2 • Let us consider the following preemptable, periodic, and independent task set: • J1: c1=40, p1=50 • J2: c2=4, p2=10 • J3: c3=5, p3=25 • J4: c4=6, p4=10. • compute the utilization rate. • check the applicability of schedulability test 10. • find a feasible schedule for the above task set. • if the above tasks are non-preemptable, is there any feasible schedule for it? COSC-4301-01, Lecture 4
Scheduling Periodic Tasks. Example 2 • U = 2, hence two processors are needed to schedule the above task set. • T = GCD(50, 10, 25, 10) = 5 • t = GCD(T, T(c1/p1), T(c2/p2), T(c3/p3), T(c4/p4)) = GCD(5, 5*40/50, 5*4/10, 5*5/25, 5*6/10) = 1. • Since the value of t is integral, a feasible schedule exists for this task. COSC-4301-01, Lecture 4
Scheduling Periodic Tasks. Example 2 • Scheduling for preemptable task set using two processors and RM Scheduling algorithm: COSC-4301-01, Lecture 4
Scheduling Periodic Tasks. Example 2 • Scheduling for non-preemptable task set using two processors: COSC-4301-01, Lecture 4
Available scheduling tools • A variety of tools are available for scheduling and schedulability analysis of real-time tasks. • Three of these are: • PERTS (also called RAPID RMA) is downloadable from http://www.tripac.com/ • PerfoRMAx is downloadable from http://www.aonix.com/ • TimeWiz is downloadable from (n.t., obsolete) http://www.timesys.com/ COSC-4301-01, Lecture 4
Available real-time operating systems • The goals of conventional, non-real-time operating systems are to provide a convenient interface between the user and the computer hardware while attempting to maximize average throughput, to minimize average time for tasks, and to ensure the fair and correct sharing of resources. • However, meeting task deadlines is not an essential objective in non-real-time operating systems since its scheduler usually does not consider the deadlines of individual tasks when making scheduling decisions. COSC-4301-01, Lecture 4
Available real-time operating systems • For real-time applications in which task deadlines must be satisfied, a real-time operating system (RTOS) with an appropriate scheduler for scheduling tasks with timing constraints must be used. • Since the late 1980s, several experiments as well as commercial RTOSs have been developed, most of which are extensions and modifications of existing operating systems such as UNIX. • Most current RTOSs conform to the IEEE POSIX standard and its real-time extensions. COSC-4301-01, Lecture 4
Commercial real-time operating systems • LynxOS (http://www.lynx.com/) is Lynux’s hard RTOS based on the LINUX. It is scalable, Linux-compatible, and highly deterministic. • RTMX O/S (http://www.rtmx.com/) has support for X11 and motif on M68K, MIPS, SPARC and PowerPC processors. • VxWorks and pSOSystem (http://www.winddriver.com/products/html/os.html) are Wind River’s RTOS’s with a flexible, scalable, and reliable architecture for most CPU platforms. COSC-4301-01, Lecture 4
Summary • Multiprocessor scheduling • Available scheduling tools • Available real-time operating systems COSC-4301-01, Lecture 4
Reading suggestions • From [Cheng; 2002] • Chapter 3, sections 3.3, 3.4, 3.5 • Chapters 3, 10 and 11 of [Kopetz; 1997] • Chapter 2 of [Stankovic, Spuri, Ramamritham, Buttazzo; 1998] COSC-4301-01, Lecture 4
Coming up next • SAT-based Scheduling COSC-4301-01, Lecture 4
Thank you for your attention!Questions? COSC-4301-01, Lecture 4