It 606 embedded systems software
Download
1 / 46

Lecture 4 - PowerPoint PPT Presentation


  • 426 Views
  • Updated On :

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

loader
I am the owner, or an agent authorized to act on behalf of the owner, of the copyrighted work described.
capcha
Download Presentation

PowerPoint Slideshow about 'Lecture 4' - jacob


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.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.


- - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - -
Presentation Transcript
It 606 embedded systems software l.jpg
IT-606Embedded Systems(Software)

S. Ramesh

Kavi Arya

Krithi Ramamritham

KReSIT/ IIT Bombay



Layered organization conventional view l.jpg
Layered Organization:Conventional View

Application Tasks

Scheduling,

IP Communication

OS

I/O Handlers

Hardware


Layered organization esterel view l.jpg
Layered Organization:Esterel View

Esterel Program +

Data Handler

Esterel Application

I/O Handlers

Bare Machine



An esterel program l.jpg
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


An esterel program contd l.jpg
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


Signals and sensors l.jpg
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


Signals and sensors9 l.jpg
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


Variables and expressions l.jpg
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


Variables and expressions11 l.jpg
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


Types and functions l.jpg
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


Functions and procedures l.jpg
Functions and Procedures

  • Their type specifications given in the program

  • their definition is written in the host language

  • value and reference parameters (like Pascal)


Modules l.jpg
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


Declaration l.jpg
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


Modules16 l.jpg
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.


Execution model l.jpg
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


Reaction l.jpg
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


Reaction19 l.jpg
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


Statements l.jpg
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


Basic statements l.jpg
Basic Statements

  • {x:=expr}

    • classical assignment statement

    • terminates instantaneously

  • emit S

    • terminates instantaneously generating a pure signal S


Basic statements contd l.jpg
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


Classical control structures l.jpg
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


Classical control structures contd l.jpg
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


Loop statement l.jpg
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


Signal testing l.jpg
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


Synchronous parallelism l.jpg
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


Synchronous parallelism28 l.jpg
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?


Preemption statements l.jpg
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


Example l.jpg
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.


Example31 l.jpg
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


Await statements l.jpg
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


A generalized await statement l.jpg
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


Nesting of aborts l.jpg
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


Weak abort l.jpg
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


Example36 l.jpg
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


Traps and exits l.jpg
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


Traps and exits38 l.jpg
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


Traps and exits contd l.jpg
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


Traps and exits contd40 l.jpg
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


Process suspension l.jpg
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


Process suspension contd l.jpg
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


Local signal declarations l.jpg
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


Module instantiation l.jpg
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


Module instantiation contd l.jpg
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


A more general instantiation l.jpg
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


ad