From Simulation to Execution: From Simulation to Execution: on a - - PowerPoint PPT Presentation

from simulation to execution from simulation to execution
SMART_READER_LITE
LIVE PREVIEW

From Simulation to Execution: From Simulation to Execution: on a - - PowerPoint PPT Presentation

Computing Science From Simulation to Execution: From Simulation to Execution: on a Certain Programming Paradigm for on a Certain Programming Paradigm for Reactive Systems Reactive Systems Pawel Gburzynski Department of Computing Science


slide-1
SLIDE 1

1 Wisla, November 2006

Computing Science

From Simulation to Execution:

  • n a Certain Programming Paradigm for

Reactive Systems From Simulation to Execution:

  • n a Certain Programming Paradigm for

Reactive Systems

Pawel Gburzynski Department of Computing Science University of Alberta & Olsonet Communications

slide-2
SLIDE 2

2 Wisla, November 2006

Computing Science

SMURPH

A System for Modeling Unslotted Real-time PHenomena A System for Modeling Unslotted Real-time PHenomena

T A B C ta 2ta

slide-3
SLIDE 3

3 Wisla, November 2006

Computing Science

Objects

station port link ... processes packets, traffic patterns, mailboxes, timers, ...

slide-4
SLIDE 4

4 Wisla, November 2006

Computing Science

A sample code fragment

mailbox DBuffer (Packet*) { void outItem (Packet *p) { delete p; }; void setup () { setLimit (MAX_Long); }; }; ... station PMonitor : PMonitorInterface { DBuffer *DB; void setup () { PMonitorInterface::configure (); DB = create DBuffer; }; }; mailbox DBuffer (Packet*) { void outItem (Packet *p) { delete p; }; void setup () { setLimit (MAX_Long); }; }; ... station PMonitor : PMonitorInterface { DBuffer *DB; void setup () { PMonitorInterface::configure (); DB = create DBuffer; }; };

slide-5
SLIDE 5

5 Wisla, November 2006

Computing Science

A process

process SlotGen (PMonitor) { Port *ORing; DBuffer *DB; SMarker *SMark; int SCount; void setup () { ORing = S->ORing; DB = S->DB; SMark = create SMarker; SMark->fill (NONE, NONE, SlotML); setFlag (SMark->Flags, TOKEN); SCount = 0; }; states {GenSlot, XDone}; perform; }; process SlotGen (PMonitor) { Port *ORing; DBuffer *DB; SMarker *SMark; int SCount; void setup () { ORing = S->ORing; DB = S->DB; SMark = create SMarker; SMark->fill (NONE, NONE, SlotML); setFlag (SMark->Flags, TOKEN); SCount = 0; }; states {GenSlot, XDone}; perform; };

slide-6
SLIDE 6

6 Wisla, November 2006

Computing Science

A process

SlotGen::perform { state GenSlot: if (DB->nonempty ()) terminate; else { SMark->Number = SCount; ORing->transmit (SMark, XDone); } state XDone: ORing->stop (); ++SCount; Timer->wait (SegmWindow, GenSlot); }; SlotGen::perform { state GenSlot: if (DB->nonempty ()) terminate; else { SMark->Number = SCount; ORing->transmit (SMark, XDone); } state XDone: ORing->stop (); ++SCount; Timer->wait (SegmWindow, GenSlot); };

slide-7
SLIDE 7

7 Wisla, November 2006

Computing Science

SMURPH -> SIDE

Interface to outside world: mailboxes can be mapped to devices or sockets. Interface to outside world: mailboxes can be mapped to devices or sockets. Virtual time mapped to real time. This simply means that Timer delays are “actual.” Virtual time mapped to real time. This simply means that Timer delays are “actual.”

slide-8
SLIDE 8

8 Wisla, November 2006

Computing Science

A natural paradigm

Mailbox Sensor { … int getValue (); … } Mailbox Sensor { … int getValue (); … } Mailbox Actuator { … int setValue (); … } Mailbox Actuator { … int setValue (); … } Sensor *sns; … sns->wait (RECEIVE, …); … Sensor *sns; … sns->wait (RECEIVE, …); …

slide-9
SLIDE 9

9 Wisla, November 2006

Computing Science

How do we program small devices?

What is the problem? Why can't we simply use Java (just kidding)? What is the problem? Why can't we simply use Java (just kidding)? From scratch: theoretically most efficient, practically tedious and/or messy (certainly not very effective). From scratch: theoretically most efficient, practically tedious and/or messy (certainly not very effective). Some platforms do exist, e.g., TinyOS. Unfortunately, they are quite a bit into consortium-type solutions. Some platforms do exist, e.g., TinyOS. Unfortunately, they are quite a bit into consortium-type solutions.

slide-10
SLIDE 10

10 Wisla, November 2006

Computing Science

The inspiring project

To implement a simple wireless application on a card- sized microcontrolled device. To implement a simple wireless application on a card- sized microcontrolled device. Two stages:

  • High-level design and virtual implementation in

SMURPH – to verify the concept and test performance.

  • The port of SMURPH code to the micro (by hand).

Two stages:

  • High-level design and virtual implementation in

SMURPH – to verify the concept and test performance.

  • The port of SMURPH code to the micro (by hand).
slide-11
SLIDE 11

11 Wisla, November 2006

Computing Science

Multiple processes/threads

code code data data stack stack

x

shared, ROM (flash) shared, ROM (flash) needed anyway needed anyway gets in the way gets in the way

How to have threads without a stack for each of them? How to have threads without a stack for each of them? E.g., TinyOS has no threads, only:

  • callbacks (event handlers) and
  • “tasks” (non-preemptible chunks of code)

E.g., TinyOS has no threads, only:

  • callbacks (event handlers) and
  • “tasks” (non-preemptible chunks of code)
slide-12
SLIDE 12

12 Wisla, November 2006

Computing Science

A thread in PicOS

process (sniffer, sess_t) char c; entry (RC_TRY) data->packet = tcv_rnp (RC_TRY, efd); data->length = tcv_left (packet); entry (RC_PASS) if (data->user != US_READY) { wait (&data->user, RC_PASS); delay (1000, RC_LOCKED); release; } ... entry (RC_LOCKED) ... entry (RC_ENP) tcv_endp (data->packet); signal (&data->packet); proceed (RC_TRY); endprocess (1)

slide-13
SLIDE 13

13 Wisla, November 2006

Computing Science

PicOS's footprint

process process process process process process process process

RAM

shared stack

private data

  • 20 bytes of RAM per process
  • 64 bytes of (global) stack goes a long way
  • we have a non-trivial mesh system based on

MSP430F148 (with 2KB of RAM per node)

slide-14
SLIDE 14

14 Wisla, November 2006

Computing Science

TCV plugin model

the micro the micro the kernel the kernel pluggable transceiver interface (TCV) pluggable transceiver interface (TCV) application application TARP TARP MAC MAC radio radio phy radio radio API plugs TCP/IP? TCP/IP?

slide-15
SLIDE 15

15 Wisla, November 2006

Computing Science

Plugin interface

typedef struct { int (*tcv_ope) (int, int, ...); int (*tcv_clo) (int, int); int (*tcv_rcv) (int, address, int, int*, tcvadp_t*); int (*tcv_frm) (address, int, tcvadp_t*); int (*tcv_out) (address); int (*tcv_xmt) (address); int (*tcv_tmt) (address); int tcv_info; } tcvplug_t;

how to open a session how to close a session preprocessing upon reception application packet boundary preprocessing for output after packet transmission

  • n timeout