Presentation is loading. Please wait.

Presentation is loading. Please wait.

1 EE249 Scheduling. 2 EE249 What’s the problem? l Have some work to do –know subtasks l Have limited resources l Have some constraints to meet l Want.

Similar presentations


Presentation on theme: "1 EE249 Scheduling. 2 EE249 What’s the problem? l Have some work to do –know subtasks l Have limited resources l Have some constraints to meet l Want."— Presentation transcript:

1 1 EE249 Scheduling

2 2 EE249 What’s the problem? l Have some work to do –know subtasks l Have limited resources l Have some constraints to meet l Want to optimize quality

3 3 EE249 Outline l Overview –shop scheduling –data-flow scheduling –real-time scheduling –OS scheduling l Real-time scheduling l RTOS generation – scheduling –Communication l Data-flow scheduling –pure –Petri nets

4 4 EE249 Shop scheduling Single job, one time l finite and known amount of work l multiple resources of different kind l often minimize lateness –could add release, precedence, deadlines,... SOLUTION: compute the schedule APPLICATION: manufacturing

5 5 EE249 Data-flow scheduling Single-job, repeatedly l known amount of work –simple subtasks l multi-processor l max. throughput, min. latency SOLUTION: code generation APPLICATION: signal processing

6 6 EE249 Data-flow scheduling variants l Work –data dependent (BDF, FCPN) l Resources –many different execution units (HLS) l Goal –min. code, min. buffers, min. resources

7 7 EE249 Real-time scheduling Fixed number of repeating jobs l each job has fixed work –job is a sub-task l processor(s) l meet individual deadlines SOLUTION: choose policy, let RTOS implement it APPLICATION: real-time control

8 8 EE249 RT scheduling variants l Work –sporadic or event-driven tasks, –variable (data dependent) work –coordination between tasks: –mutual exclusion, precedence, … l Goal –event loss, input or output correlation, freshness, soft deadlines,...

9 9 EE249 OS scheduling Variable number of random tasks l know nothing about sub-tasks l processor + other computer resources l progress of all tasks, average service time SOLUTION: OS implements time-slicing APPLICATION: computer systems

10 10 EE249 Outline l Overview –shop scheduling –data-flow scheduling –real-time scheduling –OS scheduling l Real-time scheduling l RTOS generation –Scheduling –Communication l Data-flow scheduling –pure –Petri nets

11 11 EE249 RTOS functions l Enable communication between software tasks, hardware and other system resources l Coordinate software tasks –keep track which tasks are ready to execute –decide which one to execute: scheduling

12 12 EE249 Outline l Implementing communication through events l Coordination: –classic scheduling results –reactive model of real-time systems –conservative scheduling analysis –priority assignment

13 13 EE249 The scheduling problem l Given: –estimates on execution times of each task –timing constraints l Find: –an execution ordering of tasks that satisfies constraints l A schedule needs to be: –constructed –validated

14 14 EE249 Off-line vs. on-line scheduling l Plus side: –simpler –lower overhead –highly predictable l Minus side –bad service to urgent tasks –independent of actual requests

15 15 EE249 Scheduling Algorithms l off-line (pre-run-time, static) –round-robin, e.g. – C1 C2 C3 C4 C1 C2 C3 C4 C1 C2 C3 C4 … –static cyclic, e. g. –C1 C2 C3 C2 C4 C1 C2 C3 C2 C4 C1 C2 … l on-line (run-time, dynamic) –static priority –dynamic priority –preemptive or not

16 16 EE249 Static priority scheduling l synthesis: –priority assignment –RMS [LL73] l analysis – Audsley 91

17 17 EE249 Rate Monotonic Scheduling l Liu -Layland [73] consider systems consisting of tasks: –enabled periodically –with fixed run time –that should be executed before enabled again –scheduled preemptively with statically assigned priorities

18 18 EE249 Rate Monotonic Scheduling l giving higher priority to tasks with shorter period (RMS) is optimal –if any other static priority assignment can schedule it, them RMS can do it too l define utilization as sum of E i /T i l any set of n tasks with utilization of less than n(2 1/n -1) is schedulable l for n=2,3,…. n(2 1/n -1) = 0.83, 0.78, … ln(2)=0.69

19 19 EE249 Static Priority Schedule Validation Audsley [91]: l for a task in Liu-Layland’s model find its worst case execution time iiii kn run time i WCET i period i time i

20 20 EE249 Audsley’s algorithm l let E i ’s be run-times, T i ’s periods l how much can i be delayed by a higher priority task k: –each execution delays it by E k –while i is executing k will be executed ciel(WCET i / T k ) l WCET i = E i + SUM k>i ciel(WCET i / T k )* E k

21 21 EE249 Solving implicit equation l iteration –WCET i,0 = E i –WCET i,n+1 = E i + SUM k>i ciel(WCET i,n / T k )* E k will converge if processor utilization if less than 1

22 22 EE249 Dynamic priority l Earliest deadline first: –at each moment schedule a task with the least time before next occurrence l LL have shown that for their model, EDF schedules any feasible set of tasks

23 23 EE249 What’s wrong with LL model? l Liu-Layland model yields strong results but does not model reactivity well l Our model: –models reactivity directly –abstracts functionality –allows efficient conservative schedule validation

24 24 EE249 Computation Model l System is a network of internal and external tasks l External tasks have minimum times between execution l Internal tasks have priorities and run times 20 10 1,21,25,25,23,23,2 2,12,14,14,1

25 25 EE249 Computation Model 20 10 1,21,25,25,23,23,2 2,12,14,14,1 l External task execute at random, respecting the lower bound between executions l Execution of a task enables all its successors l Correct if no events are lost

26 26 EE249 Schedule Validation l To check correctness: –check whether internal events can be lost –priority analysis –check whether external events can be lost –bound WCET

27 27 EE249 Validation for Internal Events Simple: if priority of i is less than k, then (i,k) cannot be lost ik ik More general: if fan-ins of i form a tree such that leaves have lower priority than non-leaves and k, then (i,k) cannot be lost

28 28 EE249 Validation for External Events Compute a bound on the period of time a processor executes task of priority i or higher ( i -busy period) ii > i time > i < i i-busy period > i ( i -busy period ) > ( WCET i )

29 29 EE249 Bounding i -busy Period i -busy period is bounded by: –initial workload at priority level i or higher caused by execution of some task < i –workload at priority level i or higher caused by execution of external tasks during the i -busy period can find (by simulation) workload at priority level i or higher caused by execution of a single task l can bound the number of occurrences of external tasks in a given period l need to solve a fix-point equation

30 30 EE249 System: Network of CFSMs CFSM2 CFSM3 C=>G CFSM1 C=>F B=>C F^(G==1) (A==0)=>B C=>A C=>B F G C C B A

31 31 EE249 Implementations l CFSMs can be implemented: –in hardware: HW-CFSMs –in software: SW-CFSMs –by built-in peripherals (e.g. timer): MP-CFSMs

32 32 EE249 Events: SW to SW l for every event, RTOS maintains –global values –local flags CFSM1 CFSM2 CFSM3 emit x( 3 ) x x x 3 detect x

33 33 EE249 Events: atomicity problems l TASK 1 detects y AND NOT x, which is never true l to avoid, need atomic detects TASK 1 detect x detect y TASK 2 emit x TASK 3 if detect x then emit y

34 34 EE249 Events: SW to SW l for atomicity: –always read from frozen –others always write to live –at the beginning of execution, switch CFSM frozenlive

35 35 EE249 Events: HW to SW l event can be polled or driving an interrupt l for polled events: –allocate I/O port bits for value, occurrence and acknowledge flags –generate the polling task that acknowledges and emits all polled events that have occurred l for events driving an interrupt: –allocate I/O port bits for value, –allocate an interrupt vector, –create an interrupt service routine that emits an event

36 36 EE249 Events: interrupts l interrupt service routine: l optional interrupt service routine: { emit x } X RTOSRTOS X HW-CFSM SW-CFSM IRQ { emit x execute SW-CFSM }

37 37 EE249 Events: SW to HW l allocate I/O port bits for value and occurrence flag l use existing ports or memory-mapped ports l write value to I/O port l create a pulse on occurrence flag

38 38 EE249 Events: SW to/from MP l every peripheral must have a library with –init function (to be called at initialization time) –deliver function for each input (to be called by emit) –detect function for each output (to be called by poll-taker) –interrupt service routine (containing emit)

39 39 EE249 Coordination l consider SW-CFSM ready to run whenever it has some not consumed input events l choose the next ready SW-CFSM to run: – scheduling problem

40 40 EE249 Experiments l dashboard –6 tasks, 13 events –0.1s (8.6s to estimate run times) l shock absorber controller –48 tasks, 11 events –0.3s (880s to estimate run times) l PATHO RTOS –orders of magnitude faster than timed automata –scales linearly

41 41 EE249 Open Problems l Propagation of constraints from external I/O behavior to each CFSM –probabilistic: Markov chains –exact: FSM state traversal l Satisfaction of constraints within a single transition (e.g., software-driven bus interface protocol) l Automatic choice of scheduling algorithm, based on performance estimation and constraints l Scheduling for verifiability

42 42 EE249 Outline l Overview –shop scheduling –data-flow scheduling –real-time scheduling –OS scheduling l Real-time scheduling l RTOS generation – scheduling –Communication l Data-flow scheduling –pure –Petri nets

43 43 EE249 Data-flow scheduling l Functionality usually represented with a data-flow graph l Kahn’s conditions allow scheduling freedom –if a computation is specified with actors (operators) and data dependency, and –every actor waits for data on all inputs before firing, and –no data is lost –then the firing order doesn’t matter

44 44 EE249 Data-flow graphs l Schedule: a firing order that respects data-flow constraints and returns the graph to initial state A, 1B, 2 D, 1 C, 3

45 45 EE249 Schedule implementation Static scheduling (cyclic executive, round robin) l A, B, C, D are processes l RTOS schedules them repeatedly in order A D B C l simple, but context-switching overhead large A, 1B, 2 D, 1 C, 3 A D B C A schedule:

46 46 EE249 Schedule implementation Code synthesis (OS generation) l A, B, C, D are subroutines generate: forever{ call A; call D; call B; call C; } l less robust, better overhead A, 1B, 2 D, 1 C, 3 A D B C A schedule:

47 47 EE249 Schedule implementation In-lined code synthesis l A, B, C, D are code fragments generate: forever{A; D; B; C; } l even less robust, even better overhead A, 1B, 2 D, 1 C, 3 A D B C A schedule:

48 48 EE249 Data-flow scheduling Resources l fixed or arbitrary number of processors Goal: l max. throughput given a fixed number of processors l min. processors to achieve required throughput

49 49 EE249 Data-flow scheduling goals Max. throughput given a fixed number of processors l it is NP-hard to determine max. achievable throughput Min. processors to achieve required throughput l if there are loops than there is a fundamental upper bound l easy to compute

50 50 EE249 Throughput bound 1/max loops (Time/Delay) A, 1B, 2 D, 1 C, 3 N+2’nd output of A can be computed at least 7 time units after the Nth

51 51 EE249 Scheduling heuristics Non-overlapped scheduling l Look at one iteration l Use list scheduling algorithm (developed for shop scheduling) Overlapped scheduling l less developed

52 52 EE249 Inter-iteration constraints l Remove delayed edges l List scheduling: –maintain list of tasks that could be scheduled –schedule one with longest path A, 1B, 2 D, 1 C, 3

53 53 EE249 List scheduling l Assume two processors A, 1B, 2 D, 1 C, 3 3 3

54 54 EE249 List scheduling A, 1B, 2 D, 1 C, 3 C A P1 P2

55 55 EE249 List scheduling A, 1B, 2 D, 1 C, 3 C A P1 P2 D

56 56 EE249 List scheduling A, 1B, 2 D, 1 C, 3 C A P1 P2 DB

57 57 EE249 Inter-iteration constraints l Unfold k iteration (e.g. k=2) l Do list scheduling A1, 1B1, 2 D1, 1 C1, 3 A2, 1B2, 2 D2, 1 C2, 3

58 58 EE249 List scheduling l Rate optimal (not true in general) A1, 1B1, 2 D1, 1 C1, 3 A2, 1B2, 2 D2, 1 C2, 3 C1 A1 P1 P2 D1B1 A2 D2 C2 B2

59 59 EE249 Static data flow l Loop scheduling l Code size l Buffer size ABC 20 10

60 60 EE249 Loop scheduling ABCBCCC A (2 B (2 C)) A (2 B) (4 C) A (2 B C) (2 C) ABC 20 10

61 61 EE249 Loop scheduling and code size A (2 B (2 C)) A; for i = 1 … 2 { B; for i = 1 … 2 { C; } l single appearance schedules minimize in-lined code size ABC 20 10

62 62 EE249 Buffer size ABCBCCC 20 30 A (2 B (2 C)) 20 20 A (2 B) (4 C) 20 40 A (2 B C) (2 C) 20 30 ABC 20 10

63 63 EE249 Data-flow scheduling Perfect design-time information l Fixed amount of repeating work –data-independent l Input streams from the environment always available l Simple global constraints data dependency => Petri nets timing constraints => real-time scheduling

64 64 EE249 Other scheduling models l Problem: computation result may depend on dynamic schedule l Synchronous languages: no scheduler needed (but inapplicable to HW/SW heterogeneous systems) l Data Flow networks: deterministic computation (but blocking read is unsuitable for reactive systems) l Can we obtain determinism without losing efficiency ?


Download ppt "1 EE249 Scheduling. 2 EE249 What’s the problem? l Have some work to do –know subtasks l Have limited resources l Have some constraints to meet l Want."

Similar presentations


Ads by Google