Presentation is loading. Please wait.

Presentation is loading. Please wait.

Processes and operating systems zMultiple tasks and multiple processes. ySpecifications of process timing. zPreemptive real-time operating systems.

Similar presentations


Presentation on theme: "Processes and operating systems zMultiple tasks and multiple processes. ySpecifications of process timing. zPreemptive real-time operating systems."— Presentation transcript:

1 Processes and operating systems zMultiple tasks and multiple processes. ySpecifications of process timing. zPreemptive real-time operating systems.

2 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.) zA process is a unique execution of a program. ySeveral copies of a program may run simultaneously or at different times. zA process has its own state: yregisters; ymemory. zThe operating system manages processes.

4 Why multiple processes? zMultiple tasks means multiple processes. zProcesses help with timing complexity: ymultiple rates xmultimedia xautomotive yasynchronous input xuser interfaces xcommunication systems

5 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 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

8 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 Timing specifications on processes zRelease time: time at which process becomes ready. zDeadline: time at which process must finish.

10 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. zInitiation rate may be higher than period--- several copies of process run at once. time P1 1 P1 2 P1 3 P1 4 CPU 1 CPU 2 CPU 3 CPU 4

12 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 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. 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. MPEG system layer MPEG audio MPEG video

16 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 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 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 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 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 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 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 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 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 Cyclostatic (静态循环) /TDMA ( Time Division Multiple Access 时分多路访问) 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 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 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 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 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 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 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 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 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(); }

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(); }

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(); }

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(); }

38 Implementing processes zAll of these implementations are inadequate. zNeed better control over timing. zNeed a better mechanism than subroutines.


Download ppt "Processes and operating systems zMultiple tasks and multiple processes. ySpecifications of process timing. zPreemptive real-time operating systems."

Similar presentations


Ads by Google