Transcript lecture4
Real-Time Systems, COSC-4301-01, Lecture 4
Stefan Andrei 4/30/2020 COSC-4301-01, Lecture 4 1
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 4/30/2020 COSC-4301-01, Lecture 4 2
Overview of This Lecture Multiprocessor scheduling Available scheduling tools Available real-time operating systems 4/30/2020 COSC-4301-01, Lecture 4 3
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.
1.
2.
3.
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.
4/30/2020 COSC-4301-01, Lecture 4 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.
4/30/2020 COSC-4301-01, Lecture 4 5
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: J 1 :
S 1
J 2 :
S 2
J 3 :
S 3 = 0, c 1 = 0, c 2 = 0, c 3 = 1, D 1 = 2, D 2 = 4, D 3 = 2 = 3 = 4
4/30/2020 COSC-4301-01, Lecture 4 6
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
4/30/2020 COSC-4301-01, Lecture 4 7
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
4/30/2020 COSC-4301-01, Lecture 4 8
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
4/30/2020 COSC-4301-01, Lecture 4 9
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)
4/30/2020 COSC-4301-01, Lecture 4 10
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.
4/30/2020 COSC-4301-01, Lecture 4 11
EDF scheduler fails (ex. From slide 5) Example of two-processor system (
n=2
) for three single-instance tasks: J 1 :
S 1 = 0, c 1 = 1, D 1 = 2
J 2 :
S 2 = 0, c 2 = 2, D 2 = 3
J 3 :
S 3 = 0, c 3 = 4, D 3 = 4
J 1 and J 2 have earlier absolute deadline, so they are assigned to start.
Figure 3.26 from [Cheng; 2005], page 68
4/30/2020 COSC-4301-01, Lecture 4 12
LL scheduler wins (ex. From slide 5) At time 0, J 3 has the lowest laxity, so it is assigned to start.
The other one can be J 1 it has same laxity as J 2 ).
(since
Figure 3.27 from [Cheng; 2005], page 69
4/30/2020 COSC-4301-01, Lecture 4 13
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).
4/30/2020 COSC-4301-01, Lecture 4 14
Conflict-Free Task Sets We divide the scheduling game board in 3 regions:
R 1 (k)={J j : D j R 2 (k)={J j : L j ≤ k} ≤ k and D j > k}
R 3 (k)={J j : L j > k}
where
k
is the number time units.
Surplus computing power function:
F(k,i)=kn Σ R1 C j Σ R2 (k-L j )
, for every positive integer
k
.
4/30/2020 COSC-4301-01, Lecture 4 15
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
.
4/30/2020 COSC-4301-01, Lecture 4 16
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.
4/30/2020 COSC-4301-01, Lecture 4 17
Scheduling single-instance tasks. Example Let us consider the following preemptable single-instance task set: J 1 :
S 1 = 0, c 1 = 1, D 1 = 2
J 2 :
S 2 = 0, c 2 = 2, D 2 = 4
J 3 :
S 3
1.
= 0, c 3 = 4, D 3 = 5
how many processors do the above tasks set need to execute?
2.
check the applicability of EDF-scheduling method.
3.
4.
draw a game board and check the applicability LL-scheduling method. check the applicability of schedulability test 9.
4/30/2020 COSC-4301-01, Lecture 4 18
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.
4/30/2020 COSC-4301-01, Lecture 4 19
Scheduling game board. EDF strategy. Initial state 4/30/2020 COSC-4301-01, Lecture 4 20
Scheduling game board. Time t=1(EDF) By EDF algorithm, J 1 and J 2 execute first since their absolute deadlines are earlier than J 3 . 4/30/2020 COSC-4301-01, Lecture 4 21
Scheduling game board. Time t=2(EDF) Since J 2 reaches horizontal axis, it is completed.
4/30/2020 COSC-4301-01, Lecture 4 22
Scheduling game board. Time t=5(EDF) J 2 completes its execution at time t=5. 4/30/2020 COSC-4301-01, Lecture 4 23
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 J 1 and J 3 have laxity 1.
Hence J 1 and J 2 and J 3 move downward (vertically) moves to the left (horizontally).
4/30/2020 COSC-4301-01, Lecture 4 24
Scheduling game board. Time t=1 (LL) At time t=1, J 1 completes execution so the remaining tasks are J 2 and J 3 .
4/30/2020 COSC-4301-01, Lecture 4 25
Scheduling game board. Time t=2 (LL) At time t=2, J 2 and J 3 again move downward.
4/30/2020 COSC-4301-01, Lecture 4 26
Scheduling game board. Time t=3 (LL) 4/30/2020 COSC-4301-01, Lecture 4 27
Scheduling game board. Time t=4 (LL) 4/30/2020 COSC-4301-01, Lecture 4 28
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).
4/30/2020 COSC-4301-01, Lecture 4 29
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.
4/30/2020 COSC-4301-01, Lecture 4 30
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=c 1 /p 1 +…+c k /p k ≤n
, let
T=GCD(p 1 , …, p k )
, and
t=GCD(T,T(c 1 /p 1 ), …, T(c k /p k ))
.
A sufficient condition for feasible scheduling of this task set is
t
is integral.
4/30/2020 COSC-4301-01, Lecture 4 31
Scheduling Periodic Tasks. Example 1 Consider two processors (
n=2
) and four tasks (period = deadline): J 1 :
c 1 =32, p 1 =40
J 2 :
c 2 =3, p 2 =10
J 3 :
c 3 =4, p 3 =20
J 4 :
c 4 =7, p 4 =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).
4/30/2020 COSC-4301-01, Lecture 4 32
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
4/30/2020 COSC-4301-01, Lecture 4 33
Scheduling Periodic Tasks. Example 2 Let us consider the following preemptable, periodic, and independent task set: J 1 :
c 1 =40, p 1 =50
J 2 :
c 2 =4, p 2 =10
J 3 :
c 3 =5, p 3 =25
J 4 :
c 4 =6, p 4 =10
.
1.
compute the utilization rate.
2.
3.
4.
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?
4/30/2020 COSC-4301-01, Lecture 4 34
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(c 1 /p 1 ), T(c 2 /p 2 ), T(c 3 /p 3 ), T(c 4 /p 4 )) = 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.
4/30/2020 COSC-4301-01, Lecture 4 35
Scheduling Periodic Tasks. Example 2 Scheduling for preemptable task set using two processors and RM Scheduling algorithm: 4/30/2020 COSC-4301-01, Lecture 4 36
Scheduling Periodic Tasks. Example 2 Scheduling for non-preemptable task set using two processors: 4/30/2020 COSC-4301-01, Lecture 4 37
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/ 4/30/2020 COSC-4301-01, Lecture 4 38
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.
4/30/2020 COSC-4301-01, Lecture 4 39
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.
4/30/2020 COSC-4301-01, Lecture 4 40
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.ht
ml ) are Wind River’s RTOS’s with a flexible, scalable, and reliable architecture for most CPU platforms.
4/30/2020 COSC-4301-01, Lecture 4 41
Summary Multiprocessor scheduling Available scheduling tools Available real-time operating systems 4/30/2020 COSC-4301-01, Lecture 4 42
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] 43 4/30/2020 COSC-4301-01, Lecture 4
Coming up next SAT-based Scheduling 4/30/2020 COSC-4301-01, Lecture 4 44
4/30/2020 Thank you for your attention!
Questions?
COSC-4301-01, Lecture 4 45