Академический Документы
Профессиональный Документы
Культура Документы
Nidhi Majumder
International Institute of Information Technology Kolkata 700 091
Scheduling Algorithms
Uniprocessor Scheduling Algorithms Multiprocessor Scheduling Algorithms
Uniprocessor Scheduling
Rate Monotonic (RM) Algorithm Rate Monotonic Deferred Server (DS) Algorithm Earliest Deadline First (EDF) Algorithm Algorithms with Precedence and Exclusion Conditions Algorithms for Multiple Task Versions
4
Last assumption simplifies the whole analysis, ensures that there can be at most one iteration of any task alive at any time
6
Notations Used
n number of tasks ei execution time of task Ti Pi period of task Ti Ii phasing of task Ti, so kth period of task Ti begins at time Ii + (k 1) Pi di relative deadline of task Ti Di absolute deadline of task Ti Ri release time of task Ti
7
A Typical Example of RM
11
0 1
3 tasks with P1 = 2, P2 = 6 and P3 = 10 e1= 0.5, e2 = 2, e3 =1.5 I1 = 0, I2 = 1, I3 = 3 P1 < P2 < P3 => T1 has highest priority, followed by T2, followed by T3
21
2
12
21
3
31
4
13
31
5 6
14
7
22
8
/
t P1
e1 + e2
t / P e + t / P e + e
1 1 2 2
Li(t) = Wi(t) / t Li = min 0<= t <= Pi {Li(t)} L = max {Li} Task Ti can be feasibly scheduled iff Li <= 1 All the tasks can be scheduled iff L <= 1
12
Simple Approach
Define a fictitious periodic task of highest priority and of some chosen fictitious execution period During the time of this task, processor runs any sporadic tasks awaiting service Outside this interval, processor attends periodic tasks However if during those intervals, no sporadic tasks are waiting then processor remains idle
0 1 2 3 4 5 6 7 14 8
A Typical Example
Consider the following aperiodic tasks
Task
1 2 3
Arrival Time
0 4 5
T1 starts immediately T2 arrives at 4, as d2 < d1, it preempts T1 T3 arrives at 5, as d3 > d2, lower priority than T2, so waits When T2 finishes at 7, T3 has higher priority than T1, it runs till 17 and then finally T1 picks up
18
System has primary and alternative versions of some particular task Versions vary in execution time and quality of output IRIS task Increased Reward with Increased Service Examples Calculation of e or Several Variations
Identical Linear Reward Function, Non-identical Linear Reward Function, 0-1 Reward Function, Identical Concave Reward Function, Non-identical Concave Linear Function
21
Multiprocessor Scheduling
Optimal assignment to multiple processors in all practical cases turn out to be NP-complete So must use heuristics Schedule following some simple criteria and then expect to be lucky enough to get a feasible schedule If not feasible, modify the allocation and check eg. For periodic tasks with relative deadline equal to their periods try to maintain a utilization < n (2 1/n -1) Communication costs need to be taken care of for multiprocessors
22
References
Coffman, E. G., Computer and Job-shop Scheduling Theory, Wiley, 1976 Liu C. L. and Layland J. W., Scheduling Algorithms for Multiprogramming in a Hard-real-time Environment, JACM, 20(1), 46-61, 1973 Krishna C. M., Shin K. G., Real-time Systems, McGraw-Hill Int. Editions, 1997
24
Language issues
What is a good real-time programming language?
It enables the programmer to give directions to the computer with low probability of error It increases the clarity of thought in the domain for which it is targeted Finally improves the quality of the resulting software
Desired Characteristics
Most of them common to general-purpose programming languages
Readable Portable across platforms Modular One should be able to compile or debug the modules separately
26
Portability Issues
Programmer should have the option of specifying minimum acceptable precision of each variable irrespective of the host m/c Compilers should follow some uniform code of conduct 2 solutions
Language specs without any ambiguities Central committee to resolve ambiguities (Ada has one)
28
Solution in Ada Has a core set of features with several annexes, if a compiler writer supports an annex X, he has to support it fully
29
To handle devices, language should support the programmer to specify absolute addresses and also to insert assembly language code fragments
30
In Support of Hierarchy
Blocks Information Hiding Procedures and Functions Packages Specification + Body
Written, debugged and compiled separately Placed in a library for others use Improved security Maintenance more efficient plug and chuck with ROOTS; use ROOTS
34
A Typical Example
declare TEMPERATURE: float; TOO_HOT, TOO_COLD: exception; begin loop READ_TEMEPERATURE(TEMEPERATURE); if TEMPERATURE < 400 raise TOO_COLD; elseif TEMPERATURE > 450 raise TOO_HOT; end if; end loop; exception when TOO_COLD => put(Warning: Too Cold); when TOO_HOT => put(Warning: Too Hot); end;
37
Anonymous Exceptions
If procedure B calls procedure C and C has a declared exception XX with no handling routine, then if such an exception is raised control is returned to B B knows that an exception is raised but has no way to recognize it as not declared in B We say XX is anonymous in B and may be caught using a catchall clause when others
38
Multitasking
As real-time computers often use parallel processors, realtime languages should support concurrency procedure XYZ is
task X; task body X is -- task body end X; task Y; task body Y is -- task body end Y;
begin
-- procedure body
end XYZ;
39
Tasks (continued)
Tasks can have rendezvous points, where they wait if reached earlier Tasks can have different priority levels. The pragma (compiler directive) PRIORITY can be sued to define a static priority level Ada9X real-time annex requires every system to support at least 31 distinct priority classes, actual number being implementation dependent
40
Task Scheduling
Two common scheduling mechanism supported are FIFO and changing static priority using pragma PRIORITY However real-time systems much advanced support to implement algorithms like Rate Monotone scheduling and earliest deadline first scheduling Real-time annex offers some assistance to the programmers in the form of
Task Dispatching policy Entry Queuing Policy
41
Requirements (contd.)
Specify how soon a message is to be received after it is sent Specify how soon a message must be processed after receipt by the receiving task Specify the periodic scheduling of task Specify for each loop the maximum time allowed for processing that loop Specify upper bounds on the size of any dynamic data structures, thus specifying a bound on the time required to pass them between procedures, or to allocate and deallocate storage
43
Experimental Languages
Flex developed by Univ. of Illinois 2 distinct characteristics
Powerful constraint specifications Ability to select one from multiple algorithms
Can run imprecise computations also simply by specifying when the computation must terminate A derivative of C++ with a preprocessor
44
KAPSE Kernel Ada PSE MAPSE Minimal Ada PSE APSE Ada PSE
47
References
Young, S.J., Real-time Languages: Design and Development, Ellis Horwood, 1982 Barnes, J. G. P., Programming in Ada Plus an Overview of Ada 9X, Addison-Wesley, 1994 Krishna C. M., Shin K. G., Real-time Systems, McGraw-Hill Int. Editions, 1997 Burns A., Lister A. M., Wellings A. J., A Review of Ada Tasking, Springer-Verlag, 1987
48
Thank You
49