1 / 41

Quasi-Static Scheduling of Embedded Software Using Free-Choice Petri Nets

Quasi-Static Scheduling of Embedded Software Using Free-Choice Petri Nets. Marco Sgroi, Alberto Sangiovanni-Vincentelli. University of California at Berkeley. Luciano Lavagno. Cadence Berkeley Labs. Yosinori Watanabe. Cadence European Labs. EE249 - Fall2001. Outline. Motivation

zarita
Download Presentation

Quasi-Static Scheduling of Embedded Software Using Free-Choice Petri Nets

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Quasi-Static Scheduling of Embedded Software Using Free-Choice Petri Nets Marco Sgroi, Alberto Sangiovanni-Vincentelli University of California at Berkeley Luciano Lavagno Cadence Berkeley Labs Yosinori Watanabe Cadence European Labs EE249 - Fall2001

  2. Outline • Motivation • Scheduling Free-Choice Petri Nets • Algorithm

  3. Embedded Software Synthesis • System specification: set of concurrent functional blocks (DF actors, CFSMs, PNs, …) • Software implementation: set of concurrent software tasks • Two sub-problems: • Generate code for each task (software synthesis) • Schedule tasks dynamically (dynamic scheduling) • Goal: minimize real-time scheduling overhead

  4. Petri Nets Model

  5. Petri Nets Model t16 t13 t12 Schedule: t12, t13, t16... a = 5 c = a + b

  6. Petri Nets Model Task 1 Shared Processor Task 2 + RTOS Task 3

  7. Classes of Scheduling • Static: schedule completely determined at compile time • Dynamic: schedule determined at run-time • Quasi-Static: most of the schedule computed at compile time, some scheduling decisions made at run-time (but only when necessary)

  8. Embedded Systems Specifications Specification Scheduling Real-time Control (preemption, suspension) Dynamic Data-dependent Control (if ..then ..else, while ..do) Quasi-Static Static Data Processing (+, -, *...)

  9. Data Processing IIR 2nd order filter o(n)=k1 o(n-1) + k2 i(n) i o + *k2 *k1 Schedule: i, *k2, *k1, +, o Schedule: i, *k1, *k2, +, o

  10. Data computation (Multirate) Fast Fourier Transform Multirate Data Flow network Petri Net i o 256 256 256 256 i o FFT Schedule: ii…i FFT oo…. o Sample rate conversion 2 3 2 7 8 7 5 C A B D E F Schedule: (147A) (147B) (98C) (28D) (32E) (160F)

  11. Data-dependent Control *2 i o >0 /2 Schedule: i, if (i>0) then{ /2} else{ *2}, o • Petri Nets provide a unified model for mixed control • and data processing specifications • Free-Choice (Equal Conflict) Nets: the outcome of a choice • depends on the value of a token (abstracted non-deterministically) rather than on its arrival time

  12. Existing approaches • Lee - Messerschmitt ‘86 • Static Data Flow: cannot specify data-dependent control • Buck - Lee ‘94 • Boolean Data Flow: scheduling problem is undecidable • Thoen - Goossens - De Man ‘96 • Event graph: no schedulability check, no minimization of number of tasks • Lin ‘97 • Safe Petri Net: no schedulability check, no multi-rate • Thiele - Teich ‘99 • Bounded Petri Net: partial schedulability check, complex (reachability-based) algorithm

  13. PNs and BDF BDF network Petri Net t4 <=0 t2 F <=0 t1 F T >0 T t5 >0 >0 TFF t3 Switch/Select vs. choice/merge PNs: No correlation between different choices

  14. PNs and BDF BDF network Petri Net t2 t4 t6 t8 F t1 F T T F >0 t3 t5 t7 PNs are not-determinate

  15. PNs and BDF BDF network Petri Net t2 t4 t6 t8 F t1 F T T TF >0 t3 t5 t7 PNs are not-determinate

  16. PNs and BDF BDF network Petri Net t2 t4 t6 t8 F t1 F T T TTF >0 t3 t5 t7 PNs are not-determinate

  17. Existing approaches • Lee - Messerschmitt ‘86 • Static Data Flow: cannot specify data-dependent control • Buck - Lee ‘94 • Boolean Data Flow: scheduling problem is undecidable • Thoen - Goossens - De Man ‘96 • Event graph: no schedulability check, no minimization of number of tasks • Lin ‘97 • Safe Petri Net: no schedulability check, no multi-rate • Thiele - Teich ‘99 • Bounded Petri Net: partial schedulability check, complex (reachability-based) algorithm

  18. Scheduling Petri Nets • Petri Nets provide a unified model for mixed control and dataflow specification • Most properties are decidable • A lot of theory available • Abstract Dataflow networks by representing if-then-else structures as non-deterministic choices • Non-deterministic actors (choice and merge) make the network non-determinate according to Kahn’s definition • Free-Choice: the outcome of a choice depends on the value of a token (abstracted non-deterministically) rather than on its arrival time

  19. Bounded scheduling (Marked Graphs) • A finite complete cycle is a finite sequence of transition firings that returns the net to its initial state • Bounded memory • Infinite execution • To find a finite complete cycle solve f(s) D = 0 t1 t2 t2 t3 2 2 t1 t3 2 1 0 -2 1 D = 0 -2 f(s) D = 0 has no solution T-invariantf(s) = (4,2,1) No schedule

  20. t1t1t1t1t2t2t4 (0,0) (0,0) s = t1t1t1t1t2t2t4 Bounded scheduling (Marked Graphs) • Existence of a T-invariant is only a necessary condition • Verify that the net does not deadlock by simulating the minimal T-invariant [Lee87] t1 t2 3 2 t1 t2 t3 2 2 t3 3 2 T-invariant f(s) = (4,2,1) T-invariant f(s) = (3,2,1) Not enough initial tokens Deadlock

  21. Free-Choice Petri Nets (FCPN) Marked Graph (MG) Free-Choice Confusion (not-Free-Choice) • Free-Choice: • choice depends on token value rather than arrival time • easy to analyze (using structural methods)

  22. t7 t1 t1 t2 t2 t3 t3 t5 t5 t6 Bounded scheduling (Free-Choice Petri Nets) • Can the “adversary” ever force token overflow? t3 t5 t6 t2 t1 t4 t6

  23. t7 t1 t1 t2 t2 t4 t4 t7 Bounded scheduling (Free-Choice Petri Nets) • Can the “adversary” ever force token overflow? t3 t5 t6 t2 t1 t4 t7

  24. Bounded scheduling (Free-Choice Petri Nets) • Can the “adversary” ever force token overflow? t3 t5 t2 t7 t1 t4 t6

  25. Bounded scheduling (Free-Choice Petri Nets) • Can the “adversary” ever force token overflow? t3 t5 t2 t7 t1 t4 t6

  26. Bounded scheduling (Free-Choice Petri Nets) • Can the “adversary” ever force token overflow? t3 t5 t2 t7 t1 t4 t6

  27. Schedulability (FCPN) • Quasi-Static Scheduling • at compile time find one schedule for every conditional branch • at run-time choose one of these schedules according to the actual value of the data. S={(t1 t2 t4),(t1 t3 t5)}

  28. t2 t4 t1 t5 t3 Bounded scheduling (Free-Choice Petri Nets) • Valid schedule S • is a set of finite firing sequences that return the net to its initial state • contains one firing sequence for every combination of outcomes of the free choices t2 t4 t1 (t1t2t4) t5 t3 t2 t4 t1 (t1t3t5) t3 t5 S={(t1 t2t4),(t1t3t5)} Schedulable

  29. How to check schedulability • Basic intuition: every resolution of data-dependent choices must be schedulable • Algorithm: • Decompose (by applying the Reduction Algorithm) the given Equal Conflict Net into as many Conflict-Free components as the number of possible resolutions of the non-deterministic choices. • Check if every component is statically schedulable • Derive a valid schedule, i.e. a set of finite complete cycles one for each conflict-free component

  30. Allocatability(Hack, Teruel) • An Allocation is a control function that chooses which transition fires among several conflicting ones ( A: P T). • A Reductionis the Conflict Free Net generatedfrom one Allocation by applying the Reduction Algorithm. • A ECN is allocatableif every Reduction generated from an allocation is consistent. • Theorem:A ECN is schedulable iff • it is allocatable and • every Reduction is schedulable (following Lee)

  31. t2 t4 t6 t1 t7 t5 t2 t4 t6 t6 t1 t2 t4 t7 t1 t7 t5 t2 t4 t2 t4 t6 t6 t1 t1 t7 Reduction Algorithm t2 t4 t6 t1 t7 t5 t3 T-allocation A1={t1,t2,t4,t5,t6,t7}

  32. Conflict Relation Sets:{t2,t3},{t7,t8} T-allocations: A1={t1,t2,t4,t5,t6,t7,t9,t10} A2={t1,t3,t4,t5,t6,t7,t9,t10} A3={t1,t2,t4,t5,t6,t8,t9,t10} A4={t1,t3,t4,t5,t6,t8,t9,t10} How to find a valid schedule t2 t4 t1 t3 t5 t7 t9 t6 t8 t10

  33. t4 t2 t1 t1 t3 t5 t6 t10 t8 t6 t8 t10 Valid schedule t4 t2 t1 t1 t3 t5 t5 t7 t7 t9 t9 t6 t6 (t1 t2 t4 t6 t7 t9 t5) (t1 t2 t4 t6 t8 t10) (t1 t3 t5 t6 t7 t9 t5) (t1 t3 t5 t6 t8 t10)

  34. Task 1: { t1; if (p1) then{ t2; count(p2)++; if (count(p2) = 2) then{ t4; count(p2) = count(p2) - 2;} else{ t3; t5;} } } Task 2: { t6; t7; t5; } C code implementation t4 t2 p2 2 t1 p1 p4 t3 t5 p3 t6 t7 S={(t1 t2 t1 t2 t4 t6 t7 t5) (t1 t3 t5 t6 t7 t5)}

  35. Application example:ATM Switch • No static schedule due to: • Inputs with independent rates (need Real-Time dynamic scheduling) • Data-dependent control (can use Quasi-Static Scheduling) Incoming cells (non-periodic) Internal buffer Input cells: accept? Outgoing cells Output cells: emit? Clock (periodic)

  36. Petri Nets Model

  37. Decomposition with min # of tasks Input cell processing 2 Tasks Output cell processing

  38. Real-time scheduling of independent tasks Task 1 + RTOS Task 2 Shared Processor

  39. Functional decomposition Accept/discard cell 4 Tasks Output time selector Clock divider Output cell enabler

  40. Sw Implementation QSS Functional partitioning Number of tasks 2 5 Lines of C code 1664 2187 Clock cycles 197526 249726 ATM: experimental results Functional partitioning (4+1 tasks) QSS (2 tasks)

  41. Conclusion • Advantages of Quasi-Static Scheduling: QSS minimizes run-time overhead with respect to Dynamic Scheduling by Automatic partitioning of the system functions into a minimum number of concurrent tasks The underlying model is FCPN: can check schedulability before code generation • Future work • Larger PN classes • Code optimizations

More Related