Scheduling
-
Upload
basil-johns -
Category
Documents
-
view
25 -
download
0
description
Transcript of Scheduling
![Page 2: Scheduling](https://reader030.fdocuments.in/reader030/viewer/2022020422/56813214550346895d986ba0/html5/thumbnails/2.jpg)
2
Outline
Review. Varieties of scheduling. Static scheduling.
Feasibility.Scheduling algorithms.
![Page 3: Scheduling](https://reader030.fdocuments.in/reader030/viewer/2022020422/56813214550346895d986ba0/html5/thumbnails/3.jpg)
3
Reactive systems
Respond to external events.Engine controller.Seat belt monitor.
Requires real-time response.System architecture.Program implementation.
May require a chain reaction among multiple processors.
![Page 4: Scheduling](https://reader030.fdocuments.in/reader030/viewer/2022020422/56813214550346895d986ba0/html5/thumbnails/4.jpg)
4
Real-time systems Perform a computation to conform to external
timing constraints. Deadline frequency:
Periodic. Aperiodic.
Deadline type: Hard: failure to meet deadline causes system failure. Soft: failure to meet deadline causes degraded
response. Firm: late response is useless but some late responses
can be tolerated.
![Page 5: Scheduling](https://reader030.fdocuments.in/reader030/viewer/2022020422/56813214550346895d986ba0/html5/thumbnails/5.jpg)
5
Why scheduling?
The CPU is often shared among several processes. Cost. Energy/power. Physical constraints.
Someone must be responsible for giving the CPU to processes. Co-operation between processes. RTOS.
![Page 6: Scheduling](https://reader030.fdocuments.in/reader030/viewer/2022020422/56813214550346895d986ba0/html5/thumbnails/6.jpg)
6
Why CPU scheduling is not like hardware scheduling Large variation in run times. Asynchronous system architecture—no
global clock to control processes. Larger data-dependent variations in run
time, coupled with greater desire to take advantage of slack times.
Processes may have variable start times.
![Page 7: Scheduling](https://reader030.fdocuments.in/reader030/viewer/2022020422/56813214550346895d986ba0/html5/thumbnails/7.jpg)
7
Processes
A process is a unique execution of a program.Several copies of a program may run
simultaneously or at different times. A process has its own state:
registers;memory.
The operating system manages processes.
![Page 8: Scheduling](https://reader030.fdocuments.in/reader030/viewer/2022020422/56813214550346895d986ba0/html5/thumbnails/8.jpg)
8
Timing requirements on processes Period: interval between process
activations. Rate: reciprocal of period. Initiation time: time at which process
becomes ready. Deadline: time at which process must
finish.
![Page 9: Scheduling](https://reader030.fdocuments.in/reader030/viewer/2022020422/56813214550346895d986ba0/html5/thumbnails/9.jpg)
9
Process characteristics
Process execution time Ti. Execution time in absence of preemption. Possible time units: seconds, clock cycles. Worst-case, best-case execution time may be useful in
some cases. Sources of variation:
Data dependencies. Memory system. CPU pipeline.
![Page 10: Scheduling](https://reader030.fdocuments.in/reader030/viewer/2022020422/56813214550346895d986ba0/html5/thumbnails/10.jpg)
10
State of a process
A process can be in one of three states: executing on the CPU; ready to run; waiting for data.
executing
ready waiting
gets dataand CPU
needsdata
gets data
needs data
preemptedgetsCPU
![Page 11: Scheduling](https://reader030.fdocuments.in/reader030/viewer/2022020422/56813214550346895d986ba0/html5/thumbnails/11.jpg)
11
The scheduling problem
Can we meet all deadlines?Must be able to meet deadlines in all cases.
How much CPU horsepower do we need to meet our deadlines?
![Page 12: Scheduling](https://reader030.fdocuments.in/reader030/viewer/2022020422/56813214550346895d986ba0/html5/thumbnails/12.jpg)
12
Scheduling metrics
CPU utilization:Fraction of the CPU that is doing useful work.Often calculated assuming no scheduling
overhead. Utilization:
U = [ t1 ≤ t ≤ t2 T(t) ] / [t2 – t1]
![Page 13: Scheduling](https://reader030.fdocuments.in/reader030/viewer/2022020422/56813214550346895d986ba0/html5/thumbnails/13.jpg)
13
Scheduling feasibility
Resource constraints make schedulability analysis NP-hard.Must show that the
deadlines are met for all timings of resource requests.
P1 P2
I/O device
![Page 14: Scheduling](https://reader030.fdocuments.in/reader030/viewer/2022020422/56813214550346895d986ba0/html5/thumbnails/14.jpg)
14
Simple processor feasibility
Assume:No resource conflicts.Constant process
execution times. Require:
T ≥ i Ti
Can’t use more than 100% of the CPU.
T1 T2 T3
T
![Page 15: Scheduling](https://reader030.fdocuments.in/reader030/viewer/2022020422/56813214550346895d986ba0/html5/thumbnails/15.jpg)
15
Hyperperiod
Hyperperiod: least common multiple (LCM) of the task periods.
Must look at the hyperperiod schedule to find all task interactions.
Hyperperiod can be very long if task periods are not chosen carefully.
![Page 16: Scheduling](https://reader030.fdocuments.in/reader030/viewer/2022020422/56813214550346895d986ba0/html5/thumbnails/16.jpg)
16
Hyperperiod example Long hyperperiod:
P1 7 ms. P2 11 ms. P3 15 ms. LCM = 1155 ms.
Shorter hyperperiod: P1 8 ms. P2 12 ms. P3 16 ms. LCM = 96 ms.
![Page 17: Scheduling](https://reader030.fdocuments.in/reader030/viewer/2022020422/56813214550346895d986ba0/html5/thumbnails/17.jpg)
17
Simple processor feasibility example P1 period 1 ms, CPU
time 0.1 ms. P2 period 1 ms, CPU
time 0.2 ms. P3 period 5 ms, CPU
time 0.3 ms.
LCM 5.00E-03peirod CPU time CPU time/LCM
P1 1.00E-03 1.00E-04 5.00E-04P2 1.00E-03 2.00E-04 1.00E-03P3 5.00E-03 3.00E-04 3.00E-04
total CPU/LCM 1.80E-03utilization 3.60E-01
![Page 18: Scheduling](https://reader030.fdocuments.in/reader030/viewer/2022020422/56813214550346895d986ba0/html5/thumbnails/18.jpg)
18
Cyclostatic/TDMA
Schedule in time slots.Same process
activation irrespective of workload.
Time slots may be equal size or unequal.
T1 T2 T3
P
T1 T2 T3
P
![Page 19: Scheduling](https://reader030.fdocuments.in/reader030/viewer/2022020422/56813214550346895d986ba0/html5/thumbnails/19.jpg)
19
TDMA assumptions
Schedule based on least common multiple (LCM) of the process periods.
Trivial scheduler -> very small scheduling overhead.
P1 P1 P1
P2 P2
PLCM
![Page 20: Scheduling](https://reader030.fdocuments.in/reader030/viewer/2022020422/56813214550346895d986ba0/html5/thumbnails/20.jpg)
20
TDMA schedulability
Always same CPU utilization (assuming constant process execution times).
Can’t handle unexpected loads.Must schedule a time slot for aperiodic
events.
![Page 21: Scheduling](https://reader030.fdocuments.in/reader030/viewer/2022020422/56813214550346895d986ba0/html5/thumbnails/21.jpg)
21
TDMA schedulability example
TDMA period = 10 ms.
P1 CPU time 1 ms. P2 CPU time 3 ms. P3 CPU time 2 ms. P4 CPU time 2 ms.
TDMA period 1.00E-02CPU time
P1 1.00E-03P2 3.00E-03P3 2.00E-03P4 2.00E-03total 8.00E-03utilization 8.00E-01
![Page 22: Scheduling](https://reader030.fdocuments.in/reader030/viewer/2022020422/56813214550346895d986ba0/html5/thumbnails/22.jpg)
22
Round-robin Schedule process
only if ready. Always test
processes in the same order.
Variations: Constant system
period. Start round-robin
again after finishing a round.
T1 T2 T3
P
T2 T3
P
![Page 23: Scheduling](https://reader030.fdocuments.in/reader030/viewer/2022020422/56813214550346895d986ba0/html5/thumbnails/23.jpg)
23
Round-robin assumptions
Schedule based on least common multiple (LCM) of the process periods.
Best done with equal time slots for processes.
Simple scheduler -> low scheduling overhead.Can be implemented in hardware.
![Page 24: Scheduling](https://reader030.fdocuments.in/reader030/viewer/2022020422/56813214550346895d986ba0/html5/thumbnails/24.jpg)
24
Round-robin schedulability
Can bound maximum CPU load.May leave unused CPU cycles.
Can be adapted to handle unexpected load.Use time slots at end of period.
![Page 25: Scheduling](https://reader030.fdocuments.in/reader030/viewer/2022020422/56813214550346895d986ba0/html5/thumbnails/25.jpg)
25
Priority-driven scheduling
Each process has a priority. CPU runs the highest-priority process that
is ready. Priorities determine scheduling policy:
fixed priority; time-varying priorities.
![Page 26: Scheduling](https://reader030.fdocuments.in/reader030/viewer/2022020422/56813214550346895d986ba0/html5/thumbnails/26.jpg)
26
Priority-driven scheduling example Rules:
each process has a fixed priority (1 highest);highest-priority ready process gets CPU;process continues until done.
ProcessesP1: priority 1, execution time 10P2: priority 2, execution time 30P3: priority 3, execution time 20
![Page 27: Scheduling](https://reader030.fdocuments.in/reader030/viewer/2022020422/56813214550346895d986ba0/html5/thumbnails/27.jpg)
27
Priority-driven scheduling example
time
P2 ready t=0 P1 ready t=15P3 ready t=18
0 3010 20 6040 50
P2 P2P1 P3
![Page 28: Scheduling](https://reader030.fdocuments.in/reader030/viewer/2022020422/56813214550346895d986ba0/html5/thumbnails/28.jpg)
28
Priority-driven schedulability
Depends on priorities:Dynamic vs. static.Relationship to process execution times.
Results depend on discipline:RMS.EDF.
![Page 29: Scheduling](https://reader030.fdocuments.in/reader030/viewer/2022020422/56813214550346895d986ba0/html5/thumbnails/29.jpg)
29
Schedulability and CPU selection
How fast a CPU do we need to make our system of processes schedulable?Process execution time depends on CPU.
Ideal case: process execution time scales linearly.
![Page 30: Scheduling](https://reader030.fdocuments.in/reader030/viewer/2022020422/56813214550346895d986ba0/html5/thumbnails/30.jpg)
30
Non-idealities in process scaling
Within a single CPU model:Memory speed doesn’t scale with CPU speed.
Across CPU models:Pipeline delays may vary.Memory system, etc.
![Page 31: Scheduling](https://reader030.fdocuments.in/reader030/viewer/2022020422/56813214550346895d986ba0/html5/thumbnails/31.jpg)
31
Example: Space Shuttle software error Space Shuttle’s first launch was delayed by
a software timing error:Primary control system PASS and backup
system BFS.BFS failed to synchronize with PASS.Change to one routine added delay that threw
off start time calculation.1 in 67 chance of timing problem.