Date post: | 03-Jun-2018 |
Category: |
Documents |
Upload: | paulokimura |
View: | 221 times |
Download: | 0 times |
of 38
8/12/2019 Process and Operating System (ch6-1)
1/38
2008 Wayne Wolf Overheads for Computers asComponents 2nded.
Processes and operating
systems
Multiple tasks and multiple processes.
Specifications of process timing.
Preemptive real-time operating systems.
Processes and UML.
8/12/2019 Process and Operating System (ch6-1)
2/38
2008 Wayne Wolf Overheads for Computers asComponents 2nded.
Reactive systems
Respond to external events.Engine controller.
Seat belt monitor.Requires real-time response.System architecture.
Program implementation.
May require a chain reaction amongmultiple processors.
8/12/2019 Process and Operating System (ch6-1)
3/38
Tasks and processes
A task is a functionaldescription of a
connected set ofoperations.
(Task can also meana collection of
processes.)
A process is a uniqueexecutionof a program.
Several copies of a
program may runsimultaneously or atdifferent times.
A process has its ownstate:
registers;
memory.
The operating systemmanages processes.
2008 Wayne Wolf Overheads forComputers as
Components 2nded.
8/12/2019 Process and Operating System (ch6-1)
4/38
2008 Wayne Wolf
Overheads for Computers as
Components 2nded.
Why multiple processes?
Multiple tasks means multiple processes.
Processes help with timing complexity:
multiple ratesmultimedia
automotive
asynchronous inputuser interfaces
communication systems
8/12/2019 Process and Operating System (ch6-1)
5/38
2008 Wayne Wolf
Overheads for Computers as
Components 2nded.
Multi-rate systems
Tasks may be synchronous orasynchronous.
Synchronous tasks may recur at differentrates.
Processes run at different rates based on
computational needs of the tasks.
8/12/2019 Process and Operating System (ch6-1)
6/38
2008 Wayne Wolf
Overheads for Computers as
Components 2nded.
Example: engine control
Tasks:
spark control
crankshaft sensingfuel/air mixture
oxygen sensor
Kalman filter
engine
controller
8/12/2019 Process and Operating System (ch6-1)
7/38
8/12/2019 Process and Operating System (ch6-1)
8/38
2008 Wayne Wolf
Overheads for Computers as
Components 2nded.
Real-time systems
Perform a computation to conform to externaltiming constraints.Deadline frequency:
Periodic.Aperiodic.
Deadline type:Hard: failure to meet deadline causes system failure.
Soft: failure to meet deadline causes degradedresponse.Firm: late response is useless but some late
responses can be tolerated.
8/12/2019 Process and Operating System (ch6-1)
9/38
2008 Wayne Wolf
Overheads for Computers as
Components 2nded.
Timing specifications on
processes
Release time: time at which processbecomes ready.
Deadline: time at which process mustfinish.
8/12/2019 Process and Operating System (ch6-1)
10/38
2008 Wayne Wolf
Overheads for Computers as
Components 2nded.
Release times and
deadlines
time
P1
initiatingevent
deadline
aperiodic processperiodic process initiated
at start of period
period
P1P1
deadline
periodperiodic process initiated
by event
8/12/2019 Process and Operating System (ch6-1)
11/38
Rate requirements on
processes
Period: intervalbetween processactivations.
Rate: reciprocal ofperiod.
Initiatino rate may be
higher than period---several copies ofprocess run at once.
2008 Wayne Wolf
Overheads for Computers as
Components 2nded.
time
P11
P12
P13
P14
CPU 1
CPU 2
CPU 3
CPU 4
8/12/2019 Process and Operating System (ch6-1)
12/38
2000 Morgan
Kaufman
Overheads for Computers as
Components
Timing violations
What happens if a process doesnt finishby its deadline?
Hard deadline: system fails if missed.Soft deadline: user may notice, but system
doesnt necessarily fail.
8/12/2019 Process and Operating System (ch6-1)
13/38
2008 Wayne Wolf
Overheads for Computers as
Components 2nded.
Example: Space Shuttle
software error
Space Shuttles first launch was delayedby a software timing error:
Primary control system PASS and backupsystem BFS.
BFS failed to synchronize with PASS.
Change to one routine added delay thatthrew off start time calculation.
1 in 67 chance of timing problem.
8/12/2019 Process and Operating System (ch6-1)
14/38
Task graphs
Tasks may have datadependencies---mustexecute in certain order.
Task graph showsdata/controldependencies betweenprocesses.
Task: connected set ofprocesses.
Task set: One or moretasks.
2008 Wayne Wolf
Overheads for Computers as
Components 2nded.
P3
P1 P2
P4
P5
P6
task 1 task 2
task set
8/12/2019 Process and Operating System (ch6-1)
15/38
Communication between
tasks
Task graph assumes thatall processes in each taskrun at the same rate,
tasks do notcommunicate.
In reality, some amountof inter-task
communication isnecessary.
Its hard to requireimmediate response formulti-rate communication.
2008 Wayne Wolf
Overheads for Computers as
Components 2nded.
MPEG
system
layer
MPEG
audio
MPEG
video
8/12/2019 Process and Operating System (ch6-1)
16/38
2008 Wayne Wolf
Overheads for Computers as
Components 2nded.
Process execution
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 usefulin some cases.
Sources of variation:
Data dependencies.Memory system.
CPU pipeline.
8/12/2019 Process and Operating System (ch6-1)
17/38
2008 Wayne Wolf
Overheads for Computers as
Components 2nded.
Utilization
CPU utilization:
Fraction of the CPU that is doing useful work.
Often calculated assuming no schedulingoverhead.
Utilization:
U = (CPU time for useful work)/(total available CPU time)= [ St1 t t2T(t) ] / [t2t1]
= T/t
8/12/2019 Process and Operating System (ch6-1)
18/38
2008 Wayne Wolf
Overheads for Computers as
Components 2nded.
State of a process
A process can be inone of three states:
executingon the CPU;
readyto run;
waitingfor data.
executing
ready waiting
gets data
and CPU
needs
data
gets data
needs data
preemptedgets
CPU
8/12/2019 Process and Operating System (ch6-1)
19/38
2008 Wayne Wolf
Overheads for Computers as
Components 2nded.
The scheduling problem
Can we meet all deadlines?
Must be able to meet deadlines in all cases.
How much CPU horsepower do we needto meet our deadlines?
8/12/2019 Process and Operating System (ch6-1)
20/38
2008 Wayne Wolf
Overheads for Computers as
Components 2nded.
Scheduling feasibility
Resource constraintsmake schedulability
analysis NP-hard.Must show that the
deadlines are met forall timings of resource
requests.
P1 P2
I/O device
8/12/2019 Process and Operating System (ch6-1)
21/38
2008 Wayne Wolf
Overheads for Computers as
Components 2nded.
Simple processor feasibility
Assume:
No resource conflicts.
Constant processexecution times.
Require:
T SiTiCant use more than
100% of the CPU.
T1 T2 T3
T
8/12/2019 Process and Operating System (ch6-1)
22/38
2008 Wayne Wolf
Overheads for Computers as
Components 2nded.
Hyperperiod
Hyperperiod: least common multiple(LCM) of the task periods.
Must look at the hyperperiod schedule tofind all task interactions.
Hyperperiod can be very long if task
periods are not chosen carefully.
8/12/2019 Process and Operating System (ch6-1)
23/38
2008 Wayne Wolf
Overheads for Computers as
Components 2nded.
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.
8/12/2019 Process and Operating System (ch6-1)
24/38
2004 Wayne Wolf
Overheads for Computers as
Components 2nded.
Simple processor feasibility
example
P1 period 1 ms, CPUtime 0.1 ms.
P2 period 1 ms, CPUtime 0.2 ms.
P3 period 5 ms, CPUtime 0.3 ms.
LCM 5.00E-03
peirod CPU time CPU time/L
P1 1.00E-03 1.00E-04 5.00E-04
P2 1.00E-03 2.00E-04 1.00E-03
P3 5.00E-03 3.00E-04 3.00E-04
total CPU/LCM 1.80E-03
utilization 3.60E-01
8/12/2019 Process and Operating System (ch6-1)
25/38
2004 Wayne Wolf
Overheads for Computers as
Components 2nded.
Cyclostatic/TDMA
Schedule in timeslots.
Same processactivationirrespective ofworkload.
Time slots may beequal size orunequal.
T1 T2 T3
P
T1 T2 T3
P
8/12/2019 Process and Operating System (ch6-1)
26/38
2008 Wayne Wolf
Overheads for Computers as
Components 2nded.
TDMA assumptions
Schedule based onleast commonmultiple (LCM) ofthe processperiods.
Trivial scheduler -
> very smallschedulingoverhead.
P1 P1 P1
P2 P2
PLCM
8/12/2019 Process and Operating System (ch6-1)
27/38
2008 Wayne Wolf
Overheads for Computers as
Components 2nded.
TDMA schedulability
Always same CPU utilization (assumingconstant process execution times).
Cant handle unexpected loads.Must schedule a time slot for aperiodic
events.
8/12/2019 Process and Operating System (ch6-1)
28/38
2008 Wayne Wolf
Overheads for Computers as
Components 2nded.
TDMA schedulability example
TDMA period = 10ms.
P1 CPU time 1 ms.P2 CPU time 3 ms.
P3 CPU time 2 ms.
P4 CPU time 2 ms.
TDMA period 1.00E-02
CPU time
P1 1.00E-03
P2 3.00E-03
P3 2.00E-03
P4 2.00E-03
total 8.00E-03
utilization 8.00E-01
8/12/2019 Process and Operating System (ch6-1)
29/38
2008 Wayne Wolf
Overheads for Computers as
Components 2nded.
Round-robin
Schedule processonly if ready.Always test
processes in thesame order.
Variations:Constant system
period.
Start round-robinagain after finishinga round.
T1 T2 T3
P
T2 T3
P
8/12/2019 Process and Operating System (ch6-1)
30/38
2008 Wayne Wolf
Overheads for Computers as
Components 2nded.
Round-robin assumptions
Schedule based on least common multiple(LCM) of the process periods.
Best done with equal time slots forprocesses.
Simple scheduler -> low scheduling
overhead.Can be implemented in hardware.
8/12/2019 Process and Operating System (ch6-1)
31/38
2008 Wayne Wolf
Overheads for Computers as
Components 2nded.
Round-robin schedulability
Can bound maximum CPU load.
May leave unused CPU cycles.
Can be adapted to handle unexpectedload.
Use time slots at end of period.
S h d l bilit d
8/12/2019 Process and Operating System (ch6-1)
32/38
2008 Wayne Wolf
Overheads for Computers as
Components 2nded.
Schedulability and
overhead
The scheduling process consumes CPUtime.
Not all CPU time is available for processes.Scheduling overhead must be taken into
account for exact schedule.
May be ignored if it is a small fraction of totalexecution time.
R i i di
8/12/2019 Process and Operating System (ch6-1)
33/38
2008 Wayne Wolf
Overheads for Computers as
Components 2nded.
Running periodic
processes
Need code to control execution ofprocesses.
Simplest implementation: process =subroutine.
8/12/2019 Process and Operating System (ch6-1)
34/38
while loop implementation
Simplestimplementation hasone loop.
No control overexecution timing.
while (TRUE) {
p1();
p2();}
2008 Wayne Wolf
Overheads for Computers as
Components 2nded.
8/12/2019 Process and Operating System (ch6-1)
35/38
Timed loop implementation
Encapuslate set of allprocesses in a singlefunction thatimplements the taskset,.
Use timer to control
execution of the task.No control over timing
of individualprocesses.
void pall(){
p1();
p2();}
2008 Wayne Wolf
Overheads for Computers as
Components 2nded.
M lti l ti
8/12/2019 Process and Operating System (ch6-1)
36/38
Multiple timers
implementation
Each task has its ownfunction.
Each task has its owntimer.
May not have enoughtimers to implement
all the rates.
void pA(){ /* rate A */
p1();
p3();
}
void B(){ /* rate B */
p2();
p4();p5();
}
2008 Wayne Wolf
Overheads for Computers as
Components 2nded.
Ti + t
8/12/2019 Process and Operating System (ch6-1)
37/38
Timer + counter
implementation
Use a software countto divide the timer.
Only works for cleanmultiples of the timerperiod.
int p2count = 0;
void pall(){
p1();
if (p2count >= 2) {
p2();
p2count = 0;
}else p2count++;
p3();
}
2008 Wayne Wolf
Overheads for Computers as
Components 2nded.
8/12/2019 Process and Operating System (ch6-1)
38/38
Implementing processes
All of these implementations areinadequate.
Need better control over timing.Need a better mechanism than
subroutines.
2008 Wayne Wolf
Overheads for Computers as
Components 2nd ed