Presentation is loading. Please wait.

Presentation is loading. Please wait.

© 2008 Wayne Wolf Overheads for Computers as Components 2 nd ed. Processes and operating systems zMultiple tasks and multiple processes. ySpecifications.

Similar presentations


Presentation on theme: "© 2008 Wayne Wolf Overheads for Computers as Components 2 nd ed. Processes and operating systems zMultiple tasks and multiple processes. ySpecifications."— Presentation transcript:

1 © 2008 Wayne Wolf Overheads for Computers as Components 2 nd ed. Processes and operating systems zMultiple tasks and multiple processes. ySpecifications of process timing. zPreemptive real-time operating systems. zProcesses and UML.

2 © 2008 Wayne Wolf Overheads for Computers as Components 2 nd ed. Reactive systems zRespond to external events. yEngine controller. ySeat belt monitor. zRequires real-time response. ySystem architecture. yProgram implementation. zMay require a chain reaction among multiple processors.

3 Tasks and processes zA task is a functional description of a connected set of operations. z(Task can also mean a collection of processes.) z A process is a unique execution of a program. ySeveral copies of a program may run simultaneously or at different times. z A process has its own state: yregisters; ymemory. z The operating system manages processes. © 2008 Wayne Wolf Overheads for Computers as Components 2 nd ed.

4 © 2008 Wayne Wolf Overheads for Computers as Components 2 nd ed. Why multiple processes? zMultiple tasks means multiple processes. zProcesses help with timing complexity: ymultiple rates xmultimedia xautomotive yasynchronous input xuser interfaces xcommunication systems

5 © 2008 Wayne Wolf Overheads for Computers as Components 2 nd ed. Multi-rate systems zTasks may be synchronous or asynchronous. zSynchronous tasks may recur at different rates. zProcesses run at different rates based on computational needs of the tasks.

6 © 2008 Wayne Wolf Overheads for Computers as Components 2 nd ed. Example: engine control zTasks: yspark control ycrankshaft sensing yfuel/air mixture yoxygen sensor yKalman filter engine controller

7 Typical rates in engine controllers VariableFull range time (ms)Update period (ms) Engine spark timing3002 Throttle402 Air flow304 Battery voltage804 Fuel flow25010 Recycled exhaust gas50025 Status switches10020 Air temperatureSeconds400 Barometric pressureSeconds1000 Spark (dwell)101 Fuel adjustment808 Carburetor50025 Mode actuators100 © 2008 Wayne Wolf Overheads for Computers as Components 2 nd ed.

8 © 2008 Wayne Wolf Overheads for Computers as Components 2 nd ed. Real-time systems zPerform a computation to conform to external timing constraints. zDeadline frequency: yPeriodic. yAperiodic. zDeadline type: yHard: failure to meet deadline causes system failure. ySoft: failure to meet deadline causes degraded response. yFirm: late response is useless but some late responses can be tolerated.

9 © 2008 Wayne Wolf Overheads for Computers as Components 2 nd ed. Timing specifications on processes zRelease time: time at which process becomes ready. zDeadline: time at which process must finish.

10 © 2008 Wayne Wolf Overheads for Computers as Components 2 nd ed. Release times and deadlines time P1 initiating event deadline aperiodic process periodic process initiated at start of period period P1 deadline period periodic process initiated by event

11 Rate requirements on processes zPeriod: interval between process activations. zRate: reciprocal of period. zInitiatino rate may be higher than period--- several copies of process run at once. © 2008 Wayne Wolf Overheads for Computers as Components 2 nd ed. time P1 1 P1 2 P1 3 P1 4 CPU 1 CPU 2 CPU 3 CPU 4

12 © 2000 Morgan Kaufman Overheads for Computers as Components Timing violations zWhat happens if a process doesn’t finish by its deadline? yHard deadline: system fails if missed. ySoft deadline: user may notice, but system doesn’t necessarily fail.

13 © 2008 Wayne Wolf Overheads for Computers as Components 2 nd ed. Example: Space Shuttle software error zSpace Shuttle’s first launch was delayed by a software timing error: yPrimary control system PASS and backup system BFS. yBFS failed to synchronize with PASS. yChange to one routine added delay that threw off start time calculation. y1 in 67 chance of timing problem.

14 Task graphs zTasks may have data dependencies---must execute in certain order. zTask graph shows data/control dependencies between processes. zTask: connected set of processes. zTask set: One or more tasks. © 2008 Wayne Wolf Overheads for Computers as Components 2 nd ed. P3 P1P2 P4 P5 P6 task 1task 2 task set

15 Communication between tasks zTask graph assumes that all processes in each task run at the same rate, tasks do not communicate. zIn reality, some amount of inter-task communication is necessary. yIt’s hard to require immediate response for multi-rate communication. © 2008 Wayne Wolf Overheads for Computers as Components 2 nd ed. MPEG system layer MPEG audio MPEG video

16 © 2008 Wayne Wolf Overheads for Computers as Components 2 nd ed. Process execution characteristics zProcess execution time T i. yExecution time in absence of preemption. yPossible time units: seconds, clock cycles. yWorst-case, best-case execution time may be useful in some cases. zSources of variation: yData dependencies. yMemory system. yCPU pipeline.

17 © 2008 Wayne Wolf Overheads for Computers as Components 2 nd ed. Utilization zCPU utilization: yFraction of the CPU that is doing useful work. yOften calculated assuming no scheduling overhead. zUtilization: yU = (CPU time for useful work )/ (total available CPU time) = [  t1 ≤ t ≤ t2 T(t) ] / [t2 – t1] = T/t

18 © 2008 Wayne Wolf Overheads for Computers as Components 2 nd ed. State of a process zA process can be in one of three states: yexecuting on the CPU; yready to run; ywaiting for data. executing readywaiting gets data and CPU needs data gets data needs data preempted gets CPU

19 © 2008 Wayne Wolf Overheads for Computers as Components 2 nd ed. The scheduling problem zCan we meet all deadlines? yMust be able to meet deadlines in all cases. zHow much CPU horsepower do we need to meet our deadlines?

20 © 2008 Wayne Wolf Overheads for Computers as Components 2 nd ed. Scheduling feasibility zResource constraints make schedulability analysis NP-hard. yMust show that the deadlines are met for all timings of resource requests. P1P2 I/O device

21 © 2008 Wayne Wolf Overheads for Computers as Components 2 nd ed. Simple processor feasibility zAssume: yNo resource conflicts. yConstant process execution times. zRequire:  T ≥  i T i yCan’t use more than 100% of the CPU. T1T1 T2T2 T3T3 T

22 © 2008 Wayne Wolf Overheads for Computers as Components 2 nd ed. Hyperperiod zHyperperiod: least common multiple (LCM) of the task periods. zMust look at the hyperperiod schedule to find all task interactions. zHyperperiod can be very long if task periods are not chosen carefully.

23 © 2008 Wayne Wolf Overheads for Computers as Components 2 nd ed. Hyperperiod example zLong hyperperiod: yP1 7 ms. yP2 11 ms. yP3 15 ms. yLCM = 1155 ms. zShorter hyperperiod: yP1 8 ms. yP2 12 ms. yP3 16 ms. yLCM = 96 ms.

24 © 2004 Wayne Wolf Overheads for Computers as Components 2 nd ed. Simple processor feasibility example zP1 period 1 ms, CPU time 0.1 ms. zP2 period 1 ms, CPU time 0.2 ms. zP3 period 5 ms, CPU time 0.3 ms.

25 © 2004 Wayne Wolf Overheads for Computers as Components 2 nd ed. Cyclostatic/TDMA zSchedule in time slots. ySame process activation irrespective of workload. zTime slots may be equal size or unequal. T1T1 T2T2 T3T3 P T1T1 T2T2 T3T3 P

26 © 2008 Wayne Wolf Overheads for Computers as Components 2 nd ed. TDMA assumptions zSchedule based on least common multiple (LCM) of the process periods. zTrivial scheduler - > very small scheduling overhead. P1P1 P1P1 P1P1 P2P2 P2P2 P LCM

27 © 2008 Wayne Wolf Overheads for Computers as Components 2 nd ed. TDMA schedulability zAlways same CPU utilization (assuming constant process execution times). zCan’t handle unexpected loads. yMust schedule a time slot for aperiodic events.

28 © 2008 Wayne Wolf Overheads for Computers as Components 2 nd ed. TDMA schedulability example zTDMA period = 10 ms. zP1 CPU time 1 ms. zP2 CPU time 3 ms. zP3 CPU time 2 ms. zP4 CPU time 2 ms.

29 © 2008 Wayne Wolf Overheads for Computers as Components 2 nd ed. Round-robin zSchedule process only if ready. yAlways test processes in the same order. zVariations: yConstant system period. yStart round-robin again after finishing a round. T1T1 T2T2 T3T3 P T2T2 T3T3 P

30 © 2008 Wayne Wolf Overheads for Computers as Components 2 nd ed. Round-robin assumptions zSchedule based on least common multiple (LCM) of the process periods. zBest done with equal time slots for processes. zSimple scheduler -> low scheduling overhead. yCan be implemented in hardware.

31 © 2008 Wayne Wolf Overheads for Computers as Components 2 nd ed. Round-robin schedulability zCan bound maximum CPU load. yMay leave unused CPU cycles. zCan be adapted to handle unexpected load. yUse time slots at end of period.

32 © 2008 Wayne Wolf Overheads for Computers as Components 2 nd ed. Schedulability and overhead zThe scheduling process consumes CPU time. yNot all CPU time is available for processes. zScheduling overhead must be taken into account for exact schedule. yMay be ignored if it is a small fraction of total execution time.

33 © 2008 Wayne Wolf Overheads for Computers as Components 2 nd ed. Running periodic processes zNeed code to control execution of processes. zSimplest implementation: process = subroutine.

34 while loop implementation zSimplest implementation has one loop. yNo control over execution timing. while (TRUE) { p1(); p2(); } © 2008 Wayne Wolf Overheads for Computers as Components 2 nd ed.

35 Timed loop implementation zEncapuslate set of all processes in a single function that implements the task set,. zUse timer to control execution of the task. yNo control over timing of individual processes. void pall(){ p1(); p2(); } © 2008 Wayne Wolf Overheads for Computers as Components 2 nd ed.

36 Multiple timers implementation zEach task has its own function. zEach task has its own timer. yMay not have enough timers 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 2 nd ed.

37 Timer + counter implementation zUse a software count to divide the timer. zOnly works for clean multiples of the timer period. int p2count = 0; void pall(){ p1(); if (p2count >= 2) { p2(); p2count = 0; } else p2count++; p3(); } © 2008 Wayne Wolf Overheads for Computers as Components 2 nd ed.

38 Implementing processes zAll of these implementations are inadequate. zNeed better control over timing. zNeed a better mechanism than subroutines. © 2008 Wayne Wolf Overheads for Computers as Components 2 nd ed.


Download ppt "© 2008 Wayne Wolf Overheads for Computers as Components 2 nd ed. Processes and operating systems zMultiple tasks and multiple processes. ySpecifications."

Similar presentations


Ads by Google