Presentation is loading. Please wait.

Presentation is loading. Please wait.

© S. Ramesh / Kavi Arya / Krithi Ramamritham 1 IT-606 Embedded Systems (Software) S. Ramesh Kavi Arya Krithi Ramamritham KReSIT/ IIT Bombay.

Similar presentations


Presentation on theme: "© S. Ramesh / Kavi Arya / Krithi Ramamritham 1 IT-606 Embedded Systems (Software) S. Ramesh Kavi Arya Krithi Ramamritham KReSIT/ IIT Bombay."— Presentation transcript:

1 © S. Ramesh / Kavi Arya / Krithi Ramamritham 1 IT-606 Embedded Systems (Software) S. Ramesh Kavi Arya Krithi Ramamritham KReSIT/ IIT Bombay

2 © S. Ramesh / Kavi Arya / Krithi Ramamritham 2 Esterel: Basic Features and Constructs S. Ramesh

3 © S. Ramesh / Kavi Arya / Krithi Ramamritham 3 Layered Organization: Conventional View Hardware I/O Handlers Application Tasks Scheduling, IP Communication OS

4 © S. Ramesh / Kavi Arya / Krithi Ramamritham 4 Layered Organization: Esterel View Bare Machine I/O Handlers Esterel Application Esterel Program + Data Handler

5 © S. Ramesh / Kavi Arya / Krithi Ramamritham 5 Layer Interaction

6 © S. Ramesh / Kavi Arya / Krithi Ramamritham 6 An Esterel program Describes the behavior of the reactive kernel –Has rich set of constructs for programming the kernel –Kernel is typically finite state Interacts with its environment through an abstract interface –Signals and Sensors are the means of communication –Input, Output and Local signals –Sensors are inputs only

7 © S. Ramesh / Kavi Arya / Krithi Ramamritham 7 An Esterel program (contd.) Has minimal data processing functions Uses the data handling part for major data processing –Functions and Tasks are the means of communication. –Global and Local variables are used for communication –Host language support - C,C++, Ada

8 © S. Ramesh / Kavi Arya / Krithi Ramamritham 8 Signals and sensors Signals are the novel means of communication idea from hardware systems software abstractions of the interface Signals can be pure or valued –pure signals have two status 'presence' or 'absence‘ –valued signals when present carry values –values are typed, like integer, boolean, string,float Signals are transient! - reset at the end of a reaction

9 © S. Ramesh / Kavi Arya / Krithi Ramamritham 9 Signals and sensors environment communicates by setting input signals program communicates back via output signals local signals are used for communication between concurrent modules has a no. of constructs for handling signals – emit S, await S, present S then … tick is a special signal always present sensors are special signals used as input only

10 © S. Ramesh / Kavi Arya / Krithi Ramamritham 10 Variables and Expressions Esterel is an imperative language and hence uses variables variables can store different types of values – integer, boolean, string, float variables retain values until updated (across reactions) variables can be local to a block of statements, a procedure or function or global no sharing of variables with the environment

11 © S. Ramesh / Kavi Arya / Krithi Ramamritham 11 Variables and Expressions No sharing of variables between concurrent threads Variables are means of communication along a single sequential thread The 'race problem' is absent! Expressions can be formed out of variables

12 © S. Ramesh / Kavi Arya / Krithi Ramamritham 12 Types and Functions Esterel is meant for controller applications Has minimal number of types Integer, boolean, float and string All other types used should be defined in the host language Functions and Procedures called during execution

13 © S. Ramesh / Kavi Arya / Krithi Ramamritham 13 Functions and Procedures Their type specifications given in the program their definition is written in the host language value and reference parameters (like Pascal)

14 © S. Ramesh / Kavi Arya / Krithi Ramamritham 14 Modules Basic programming unit –Declarations types, variables, functions and procedures (Pascal syntax) input and output signals relation constraints –Body of a module the statement executed sequential and concurrent flow of control preemption and exceptions

15 © S. Ramesh / Kavi Arya / Krithi Ramamritham 15 Declaration module TIMER: %declaration type TIME; var t:=0:integer; procedure dec(TIME)(); function zorn()(TIME):boolean; input SECOND, SET(TIME), RESET; output ALARM relation SECOND # RESET

16 © S. Ramesh / Kavi Arya / Krithi Ramamritham 16 loop abort await SET(t); trap T in loop [ if zorn(t) then exit T else nothing || await SECOND; call dec(t); ] end end; emit ALARM; when RESET; end end module. Modules

17 © S. Ramesh / Kavi Arya / Krithi Ramamritham 17 Execution Model execution is a series of reactions invoked from an external 'main' program repeatedly at discrete points of time one reaction per invocation control returns after each reaction

18 © S. Ramesh / Kavi Arya / Krithi Ramamritham 18 Reaction Considered instantaneous! Control flows from one statement to its next Concurrent control flows Input signals do not change in status nor in their values. Output and local signals may change Signal presence tested and variables updated Reaction proceeds until pause is encountered

19 © S. Ramesh / Kavi Arya / Krithi Ramamritham 19 Reaction Reaction stops when pause is encountered in all active threads Next reaction starts from the next statement Status and values of input signals are reset at the end of reaction New values are set by the environment

20 © S. Ramesh / Kavi Arya / Krithi Ramamritham 20 Statements Rich set of high level constructs –Basic Statements –Derived Statements Basic statements – Nothing does nothing, terminates instantaneously – Pause special control statement stops the current reaction does not terminate in the current reaction terminates in the next reaction

21 © S. Ramesh / Kavi Arya / Krithi Ramamritham 21 Basic Statements {x:=expr} – classical assignment statement –terminates instantaneously emit S – terminates instantaneously generating a pure signal S

22 © S. Ramesh / Kavi Arya / Krithi Ramamritham 22 Basic Statements (contd.) emit S(exp) –evaluate `exp' and emit S with the expression value sustain S –sustains the signal S, i.e. emits the signal in each instant

23 © S. Ramesh / Kavi Arya / Krithi Ramamritham 23 Classical control structures stat1; stat2 –when stat1 terminates stat2 start instantaneously if expr then stat1 else stat2 –evaluation of the expression and the execution of the branch done in the same instance

24 © S. Ramesh / Kavi Arya / Krithi Ramamritham 24 Classical control structures (contd.) call A(arg1)(arg2) –procedure call statement –transfer of control to the procedure, execution of the body and the return all done instantaneously! var x in stat – block statement – x is local in this block

25 © S. Ramesh / Kavi Arya / Krithi Ramamritham 25 Loop statement loop stat end repeated execution of stat when stat terminates it is restarted stat should not terminate instantaneously one or more pause should be there Consider loop pause end What is the behavior of this? halt is a derived statement that stands for this

26 © S. Ramesh / Kavi Arya / Krithi Ramamritham 26 Signal testing present S then stat1 else stat2 Similar to conditional statement tests the presence of a signal at the current reaction testing, branching and executing are instantaneous one of the branches could be absent

27 © S. Ramesh / Kavi Arya / Krithi Ramamritham 27 Synchronous Parallelism [stat1 || stat2 || stat3] simultaneous (not concurrent) execution of all the statements signals are used for communication signal emitted by one thread is broadcast to all other threads terminates when every stati terminates no sharing of variables compare with asynchronous parallelism

28 © S. Ramesh / Kavi Arya / Krithi Ramamritham 28 Example: [ emit S || present S then emit O1 else emit O2 || present S then emit O3 else emit O4 ] What is the behaviour of this program? Synchronous Parallelism

29 © S. Ramesh / Kavi Arya / Krithi Ramamritham 29 Preemption Statements Strong abort primitive - watchdog abort stat when S The body stat is executed only when S is not present Presence of S instantaneously kills the body No statement in stat is executed when S is present terminates either when either stat terminates or when S is present

30 © S. Ramesh / Kavi Arya / Krithi Ramamritham 30 Example emits S1 in the second instant and S2 in third instant if S is not present during these instants. if S is present in second instant then nothing happens; the whole statement exits. abort pause; emit S1; pause; emit S2 when S

31 © S. Ramesh / Kavi Arya / Krithi Ramamritham 31 Example if S is not present in the second instant but present in third instant then – S1 is emitted in the second instant, terminates in the third instant; no S2 is emitted in the third instant S in the first instant is ignored S in the first instant is not ignored if you write abort stat when immediate S

32 © S. Ramesh / Kavi Arya / Krithi Ramamritham 32 Await statements await tick –waits for the special signal tick –tick is present in every instant –equivalent to pause Consider abort halt when S This can be abbreviated as await S

33 © S. Ramesh / Kavi Arya / Krithi Ramamritham 33 A generalized await statement await case S1 do stat1 case S2 do stat2 case S3 do stat3 end waits for one of the signals to be present selects one of stati for execution selects stati only if Si is present selection is deterministic

34 © S. Ramesh / Kavi Arya / Krithi Ramamritham 34 Nesting of aborts when S1 is present, stat1 is killed and stat2 is started when S2 is present, what happens? when both S1,S2 are present, the outer abort statement is exited Consider abort stat1 when S1; stat2 when S2

35 © S. Ramesh / Kavi Arya / Krithi Ramamritham 35 Weak Abort A weaker form of watchdog The strong abort statement prevented the execution of body in the instant when it was aborted many time the body would like to write the last will at the time of aborting-some book keeping activity weak abort statement allows computation of the body at the instant of aborting weak abort stat when S

36 © S. Ramesh / Kavi Arya / Krithi Ramamritham 36 Example weak abort pause; emit S1; pause; emit S2 when S What is the difference? Weak abort statements can be nested. weak and strong statements can be nested

37 © S. Ramesh / Kavi Arya / Krithi Ramamritham 37 Traps and exits trap T in stat1 handle T do stat2 end trap Another weak preemption primitive The body stat1 may contain exit statement exit T

38 © S. Ramesh / Kavi Arya / Krithi Ramamritham 38 Traps and exits execution starts with execution of stat1 when exit T is encountered the control jumps to the handle statement handle statement is optional - control then returns to the statement following the trap statement if stat1 is terminated then the whole trap statement is exited - stat2 is not executed

39 © S. Ramesh / Kavi Arya / Krithi Ramamritham 39 Concurrent traps trap T,U,V in stat1 handle T do stat2 handle U do stat3 handle V do stat4 end trap Traps and exits (contd.)

40 © S. Ramesh / Kavi Arya / Krithi Ramamritham 40 Nested traps trap T in trap U in stat1 handle U do stat2 end trap U stat3 handle T do stat4 end trap T Traps and exits (contd.)

41 © S. Ramesh / Kavi Arya / Krithi Ramamritham 41 Process Suspension Abort statements are like ctrl-C of Unix Suspension inspired by ctrl-Z suspend stat when S behaves like stat so long as S is not present; if stat terminates then the whole terminates

42 © S. Ramesh / Kavi Arya / Krithi Ramamritham 42 Process Suspension (contd.) stat is not executed in the instants when S is present execution is resumed at the suspended point, when S is present S in the first instant is ignored; use immediate S to avoid this

43 © S. Ramesh / Kavi Arya / Krithi Ramamritham 43 Local Signal Declarations signal S in stat end signal signal S is local in stat stat does not react to any external S S emitted in stat not visible outside

44 © S. Ramesh / Kavi Arya / Krithi Ramamritham 44 Module Instantiation A program is a collection of modules Any module can be main module, defined by the user at the time of compilation modules can be instantiated in other modules module instantiation is a macro expansion

45 © S. Ramesh / Kavi Arya / Krithi Ramamritham 45 Module Instantiation (contd.) run M is the simplest instantiation. during compilation, this statement is replaced by the body all signal declarations discarded data declarations exported to the parent module

46 © S. Ramesh / Kavi Arya / Krithi Ramamritham 46 A More General Instantiation run M[X1/Y1, X2/Y2,..., Xn/Yn] X/Y means that `X renames Y' X can be a type, constant, function X can be a variable or a signal X should be declared in the module


Download ppt "© S. Ramesh / Kavi Arya / Krithi Ramamritham 1 IT-606 Embedded Systems (Software) S. Ramesh Kavi Arya Krithi Ramamritham KReSIT/ IIT Bombay."

Similar presentations


Ads by Google