1 / 46

IT-606 Embedded Systems (Software)

IT-606 Embedded Systems (Software) S . Ramesh Kavi Arya Krithi Ramamritham KReSIT/ IIT Bombay Esterel: Basic Features and Constructs S. Ramesh Layered Organization: Conventional View Application Tasks Scheduling, IP Communication OS I/O Handlers Hardware

jacob
Download Presentation

IT-606 Embedded Systems (Software)

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. IT-606Embedded Systems(Software) S. Ramesh Kavi Arya Krithi Ramamritham KReSIT/ IIT Bombay

  2. Esterel: Basic Features and Constructs S. Ramesh

  3. Layered Organization:Conventional View Application Tasks Scheduling, IP Communication OS I/O Handlers Hardware

  4. Layered Organization:Esterel View Esterel Program + Data Handler Esterel Application I/O Handlers Bare Machine

  5. Layer Interaction

  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. 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. 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. Signals and sensors • environment communicates bysetting 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 … • tickis a special signal always present • sensors are special signals used as input only

  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. 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. 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. 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. 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. 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. Modules loop abort await SET(t); trap T inloop[ if zorn(t) then exit Telse nothing|| await SECOND; call dec(t);] end end; emit ALARM;when RESET; end end module.

  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. 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. 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. 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. Basic Statements • {x:=expr} • classical assignment statement • terminates instantaneously • emit S • terminates instantaneously generating a pure signal S

  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. 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. 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 • xis local in this block

  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. 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. 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. Synchronous Parallelism 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?

  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 Sis present • terminates either when either stat terminates or when S is present

  30. Example abort pause; emit S1; pause; emit S2 when S • 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.

  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. Await statements Consider abort halt when S This can be abbreviated as await S await tick • waits for the special signal tick • tick is present in every instant • equivalent to pause

  33. A generalized await statement awaitcase S1 do stat1case S2 do stat2case 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. Nesting of aborts Consider abort abort stat1 when S1; stat2 when S2 • when S1 is present, stat1is killed and stat2 is started • when S2 is present, what happens? • when both S1,S2 are present, the outer abort statement is exited

  35. Weak Abort weak abort stat when S • 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

  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. 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. 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. Traps and exits (contd.) • Concurrent traps trap T,U,V in stat1 handle T do stat2 handle U do stat3 handle V do stat4 end trap

  40. Traps and exits (contd.) • Nested traps trap T in trap U in stat1 handle U do stat2 end trap U stat3 handle T do stat4 end trap T

  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. 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. 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. 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 instantiatedin other modules • module instantiation is a macro expansion

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

More Related