synthesis of embedded software using free-choice petri nets

30
Synthesis of Embedded Software Using Free- Choice Petri Nets

Upload: frye

Post on 23-Feb-2016

50 views

Category:

Documents


0 download

DESCRIPTION

Synthesis of Embedded Software Using Free-Choice Petri Nets. Challenges in Embedded System Design. Software development and its integration with the hardware Start with a implementation-independent specification of overall system Map it to a heterogeneous architecture …. Introduction. - PowerPoint PPT Presentation

TRANSCRIPT

Page 1: Synthesis of Embedded Software Using Free-Choice Petri Nets

Synthesis of Embedded Software Using Free-Choice Petri Nets

Page 2: Synthesis of Embedded Software Using Free-Choice Petri Nets

Challenges in Embedded System Design

• Software development and its integration with the hardware− Start with a implementation-independent

specification of overall system−Map it to a heterogeneous architecture

• …

Page 3: Synthesis of Embedded Software Using Free-Choice Petri Nets

Introduction• Embedded system specification

−Data computations • Schedule can be completely computed at compile time,.

−Control structures• Data dependent control

− like if-then-else or do loops• Real time controls

−Suspension, trigger actions after the occurrence of external or internal events.

Page 4: Synthesis of Embedded Software Using Free-Choice Petri Nets

Introduction−Schedule

• Static− static(single task, predictable, executed with no run-time

overhead)• Data dependent

− in addition to data computation, the order of operations are executed depends on the value of some data, which is known at run-time.

− quasi-static scheduling techniques computing most of the schedule at compile time, leaving at run-time only the solution of data-dependent decisions.• partition the functionality of the specification into tasks.

Page 5: Synthesis of Embedded Software Using Free-Choice Petri Nets

Introduction−Dynamic schedule• Or real-time controls, the run-time behaviour depends

on the occurrence of external events . • Classical Real-Time scheduling techniques can be

used to decide at run-time which tasks should be executed in reaction to such events.

• An ideal scheduling technique should combine the best aspects of the scheduling techniques:1. static scheduling to exploit fixed dependencies

between blocks of operations,

Page 6: Synthesis of Embedded Software Using Free-Choice Petri Nets

Introduction2. quasi-static scheduling to identify data-dependent

operations with the same rate and schedule them, 3. dynamic scheduling to determine which tasks, among

those identified at the previous step, should be executed.

• Software synthesis technique: Static and quasi-static scheduling generates sequential code and can statically allocate communication buffers.

Page 7: Synthesis of Embedded Software Using Free-Choice Petri Nets

Introduction• An effective software synthesis technique should:

1. check if the specification can be scheduled in finite memory, and thus be implemented on an embedded processor,

2. allow one to evaluate tradeoffs between memory size and execution speed of the final implementation.

— This paper: A new approach to software synthesis.

PN A set of software tasks

Page 8: Synthesis of Embedded Software Using Free-Choice Petri Nets

Introduction−Transitions: data computations ;− Places: non-FIFO channels between computation

units. −Data-dependent control : places, called choices, with

multiple output transitions, −Data: tokens passed by transitions through places,− Free-Choice (FCPNs): it has a clear distinction

between the concurrency and choice. The outcome of a choice depends on the value rather than on the arrival time of a token.

Page 9: Synthesis of Embedded Software Using Free-Choice Petri Nets

Introduction• FCPN is quasi-statically schedulable if for every

possible resolution of the control at the choice places, there exists a cyclic finite sequence that returns the tokens of the net to their initial places.

• cyclic sequences ensures that the number of data tokens that accumulate in any place is bounded even for infinite execution.

Page 10: Synthesis of Embedded Software Using Free-Choice Petri Nets

Definitions− Petri Net: (P,T,F)− Preset:− Postset:− Source, Sink−Choice or conflict: place p, |p•|>1−Marking: μ ={μ1 , μ2 , μ3 … μn }−Reachability: a marking μ’ is reachable from a

marking μ if there exists a firing sequence σ starting at marking μ and finishing at μ’.

−Boundedness: k-bounded if the number of tokens in every place of reachable marking <k

F} x)(y,|{yx• F} x)(y,|{yx

F} x)(y,|{yx

Page 11: Synthesis of Embedded Software Using Free-Choice Petri Nets

Definitions• Deadlock-freedom: no matter what marking has

been reached, it is possible to fire at least one transition of the net

− Liveness: for every reachable marking and every transition t it is possible to reach a marking that enables t.

Page 12: Synthesis of Embedded Software Using Free-Choice Petri Nets

Definitions−Common subclasses of PN:• Marked Graph: A PN such that each place p has at most

one input transition and one output transition• Conflict free Net: A PN such that each place p has at

most one output transition

• Free choice Net: A PN such that every arc from a place is either a unique outgoing arc or a unique incoming arc to a transition.

Page 13: Synthesis of Embedded Software Using Free-Choice Petri Nets

Definitions• Marked Graphs can represent concurrency and

synchronization but not conflict. • Free Choice Nets allow one to model both conflict

and synchronization, under the condition that every transition that is successor of a choice has exactly one predecessor place.

• Therefore, Free Choice Nets model data-dependent control by abstracting if-then-else control decisions as non-deterministic choices, but they can not model external conditions or multiple rendezvous.

Page 14: Synthesis of Embedded Software Using Free-Choice Petri Nets

Definitions−Cyclic Schedule: • finite complete cycle: A sequence of transition firings that

returns the net to its initial marking. The number of tokens that can accumulate in any place of the net is bounded and the net can be executed forever with bounded memory.

• a static schedule is a periodic sequence of transitions and the period is a finite complete cycle.

Page 15: Synthesis of Embedded Software Using Free-Choice Petri Nets

Definitions• To find a finite complete cycle σ, we must first solve the

state equations f(σ)T. D = 0. f(σ), called T-invariant , is a vector of times that transition ti fired in sequence σ.

• A Petri Net is consistent f(σ)T. D = 0.

• The existence of a T-invariant is a necessary, but not sufficient for a finite complete cycle to exist: deadlock can still occur if there are not enough tokens to fire any transition. once a T-invariant is obtained, it is necessary to verify that there exists a sequence σi that contains transition tj as many times as fj(σ) .

0)(fiff 0)( fiff

Page 16: Synthesis of Embedded Software Using Free-Choice Petri Nets

Qusi-static Scheduling of FCPN

0)(fiff

Page 17: Synthesis of Embedded Software Using Free-Choice Petri Nets

Qusi-static Scheduling of FCPN• Given an FCPN N and an initial marking μ0, the pair (N,μ0)

is (quasi-statically) schedulable, if there exists a valid schedule.

• Valid schedule: for each sequence σi that includes a conflict transition σij , for each transition tk that is in equal conflict relation with σij , there exists another sequence σl s.t. σi and σl are identical up to the (j-1)th transition and have respectively σij and tk at the j-th position in the sequence .

Page 18: Synthesis of Embedded Software Using Free-Choice Petri Nets

Qusi-static Scheduling of FCPN

• Σ={(t1,t2,t4),(t1,t3,t5)} is a valid schedule because for every solution of the conflict between transitions t2,and t3, it is possible to complete a cycle that returns the net to the initial marking by firing t4 after t2 or t5 after t3.

Page 19: Synthesis of Embedded Software Using Free-Choice Petri Nets

Qusi-static Scheduling of FCPN

• Σ={(t1t2t1t2t4),(t1t3t5t5)} is a valid schedule.• there is no guarantee that this happens within a cycle

because it is not possible to know a priori which transition among t2 and t3 fires.

Page 20: Synthesis of Embedded Software Using Free-Choice Petri Nets

Qusi-static Scheduling of FCPN• A valid schedule does not necessarily include all the

possible cyclic firing sequences, some even of infinite length, that can occur depending on the resolution of the non-deterministic choices. {(t1t3t5t5),(t1t2(t1t3t5t5)nt1t2t4)}

• A valid schedule should a complete set of cyclic firing sequences that ensure bounded memory execution of the net. (all the sequences that can occur)

Page 21: Synthesis of Embedded Software Using Free-Choice Petri Nets

Qusi-s S of FCPN- find a valid schedule

• Step1: Decompose the net into Conflict Free (CF) components• T-allocation :a function α: P T that chooses exactly one

among the successors of each place.• T-reduction: associated with a T-allocation is a set of subnets

generated from the image of the T-allocation using the Reduction Algorithm.

Page 22: Synthesis of Embedded Software Using Free-Choice Petri Nets
Page 23: Synthesis of Embedded Software Using Free-Choice Petri Nets
Page 24: Synthesis of Embedded Software Using Free-Choice Petri Nets
Page 25: Synthesis of Embedded Software Using Free-Choice Petri Nets

Qusi-s S of FCPN- find a valid schedule

• Step2: Check if every CF component is statically schedulable• A T-reduction Ri is schedulable if

(1)it is consistent, (2)for each source transition ts in N, it has a T-invariant Containing ts, (3)there exists a firing sequence that returns Ri to the initial marking without any deadlock when its execution is simulated

• Step 3. Derive a valid schedule, if there exists one• A net is schedulable if for all its T-reductions, each of them

corresponding to a sequence of choices, there exist a firing sequence containing at least one occurrence of every transition of the reduction.

Page 26: Synthesis of Embedded Software Using Free-Choice Petri Nets

Qusi-s S of FCPN- find a valid schedule

• Theorem: Given a FCPN, there exists a valid schedule iff every T-reduction is schedulable.

Page 27: Synthesis of Embedded Software Using Free-Choice Petri Nets

Qusi-s S of FCPN- find a valid schedule

• R1 is schedulable.

Page 28: Synthesis of Embedded Software Using Free-Choice Petri Nets

C-code generation

• The goal is:• the synthesis of a software implementation that satisfies

functional correctness minimizes a cost function of latency and memory size.

• Task: source transition with independent firing rate.

Page 29: Synthesis of Embedded Software Using Free-Choice Petri Nets

C-code generation

Page 30: Synthesis of Embedded Software Using Free-Choice Petri Nets

Experimental Result

• ATM server for virtual Private Network• Using a FCPN it has 49 t, 41 places and 11 non-deterministic

choices.