Presentation is loading. Please wait.

Presentation is loading. Please wait.

April 15, 2005TinyOS: A Component Based OSPage 1 of 27 TinyOS A Component-Based Operating System for Networked Embedded Systems Tom Bush Graduate College.

Similar presentations


Presentation on theme: "April 15, 2005TinyOS: A Component Based OSPage 1 of 27 TinyOS A Component-Based Operating System for Networked Embedded Systems Tom Bush Graduate College."— Presentation transcript:

1 April 15, 2005TinyOS: A Component Based OSPage 1 of 27 TinyOS A Component-Based Operating System for Networked Embedded Systems Tom Bush Graduate College of Union University

2 April 15, 2005TinyOS: A Component Based OSSlide 2 of 27 Overview Networked Embedded Systems Environment of TinyOS Implementation of TinyOS - nesC  Component model  Concurrency model  Compiler features Basic Example Evaluation of nesC implementation

3 April 15, 2005TinyOS: A Component Based OSSlide 3 of 27 Networked Embedded Systems What is a networked embedded system?  An interacting group of devices with computing components embedded in purpose built devices  Usually perform single task such as monitoring an environmental characteristic  Connected through some type of network  Usually not mobile, typically very small  Little if any human interaction

4 April 15, 2005TinyOS: A Component Based OSSlide 4 of 27 Networked Embedded Systems How NESs are used  Structural integrity of buildings, bridges  Monitor vehicle movements/traffic  Monitor movements of animals  Utilities data collection  Military uses Replace minefields Sniper detection

5 April 15, 2005TinyOS: A Component Based OSSlide 5 of 27 Networked Embedded Systems RF Mote Mica2 Golum Dust weC UCB Spec

6 April 15, 2005TinyOS: A Component Based OSSlide 6 of 27 Physical Constraints on NESs Relatively slow processors Small amount of memory and storage Limited battery life Must be self contained Radio or other communication Asynchronous hardware triggers

7 April 15, 2005TinyOS: A Component Based OSSlide 7 of 27 What is the TinyOS? An event-based operating system designed for wireless networked sensors Uses component based architecture Supports concurrent operations required by networked sensors Special purpose Single application (no multi-programming) Supports tasks (not threads)

8 April 15, 2005TinyOS: A Component Based OSSlide 8 of 27 TinyOS Environment NES operating system must support  Component based architecture  Tasks and event-based concurrency  Split-phase operations Commands Events

9 April 15, 2005TinyOS: A Component Based OSSlide 9 of 27 Introducing nesC A programming language for NESs  An extension of C  Static language, no dynamic memory allocation Supports concept of components and event-based concurrency model Whole program analysis & optimization

10 April 15, 2005TinyOS: A Component Based OSSlide 10 of 27 nesC Component Model Two types of components  Modules  Configurations Both types use and provide interfaces  Only point of access to components  Bi-directional; commands and events  Detailed implementation provided by components Component AComponent B

11 April 15, 2005TinyOS: A Component Based OSSlide 11 of 27 Interfaces A collection of 1 or more command and events Defines interaction boundary between components Providing component must implement the start and stop commands Using component must implement the fired event interface Timer { command result_t start( char type, uint32_t interval); command result_t stop(); event result_t fired(); }

12 April 15, 2005TinyOS: A Component Based OSSlide 12 of 27 Components Configurations  Wire other components together  Connect interfaces used by one component to those provided by another  Top level application Modules  Provide application code  Implement one or more interfaces

13 April 15, 2005TinyOS: A Component Based OSSlide 13 of 27 Example application Top Level Application Component C Component A Component B Component E Component D Provides Uses

14 April 15, 2005TinyOS: A Component Based OSSlide 14 of 27 Component Implementations configuration Blink { } implementation { components Main, BlinkM, SingleTimer, LedsC; Main.StdControl -> SingleTimer.StdControl; Main.StdControl -> BlinkM.StdControl; BlinkM.Timer -> SingleTimer.Timer; BlinkM.Leds -> LedsC; }

15 April 15, 2005TinyOS: A Component Based OSSlide 15 of 27 Component Implementations module BlinkM { provides interface StdControl; uses { interface Timer; interface Leds; } implementation { command result_t StdControl.init( ) { call Leds.init( ); return SUCCESS; } command result_t stdControl.start[int id] (char type, uint32_t interval) { return call Timer.start(Timer_Repeat, 1000); } command result_t StdControl.stop[int id]( ) { return call Timer.stop( ); } event result_t Timer.fired( ) { call Leds.redToggle( ); return SUCCESS; }

16 April 15, 2005TinyOS: A Component Based OSSlide 16 of 27 Concurrency Model Two types of concurrency in TinyOS  Tasks Travel down application graph (to HW)  Events (HW Interrupts) Travel up application graph (away from HW)

17 April 15, 2005TinyOS: A Component Based OSSlide 17 of 27 Tasks Delayed computations Posted by components Calls are non-blocking Handled by event scheduler (FIFO) Run to completion Can be preempted Do not preempt

18 April 15, 2005TinyOS: A Component Based OSSlide 18 of 27 Events Signify either  completion of a command (split-phase operation)  Hardware interrupt (environmental trigger) Run to completion Preempt tasks and other events Can call commands, post tasks, signal other events

19 April 15, 2005TinyOS: A Component Based OSSlide 19 of 27 Event/Task Example task void HandleFire() { uint8_t i; setIntervalFlag = 1; if (mState) { for (i=0;i<NUM_TIMERS;i++) { if (mState&(0x1<<i)) { mTimerList[i].ticksLeft -= (mInterval+1) ; if (mTimerList[i].ticksLeft<=2) { if (mTimerList[i].type==TIMER_REPEAT) { mTimerList[i].ticksLeft += mTimerList[i].ticks; } else {// one shot timer mState &=~(0x1<<i); } enqueue(i); post signalOneTimer(); } adjustInterval(); } async event result_t Clock.fire() { post HandleFire(); return SUCCESS; }

20 April 15, 2005TinyOS: A Component Based OSSlide 20 of 27 Concurrency Model Asynchronous code (AC) – reachable from at least one interrupt handler Synchronous code (SC) – code only reachable from tasks To prevent race conditions  Shared variables updated by SC only or in atomic code Must implement “atomic” keyword to disable interrupts when processing SC Keep atomic sections short to keep system reactive

21 April 15, 2005TinyOS: A Component Based OSSlide 21 of 27 Component Model Analysis ApplicationModules OS Modules (% of full OS) OS Modules (% of application) Lines OS Lines (% of full OS) OS Lines (% of application) Surge3127 (25%)87%28602160 (14%)76% Maté3528 (25%)80%47362524 (17%)53% TinyDB6538 (35%)58%116814160 (28%)36%

22 April 15, 2005TinyOS: A Component Based OSSlide 22 of 27 Concurrency Model Analysis nesC version 1.0  No race condition analysis  No atomic function nesC version 1.1  Added both  103 race conditions  Fixed by tasking or atomic statements

23 April 15, 2005TinyOS: A Component Based OSSlide 23 of 27 Fixing race conditions /* Contains a race: */ if (state == IDLE) { state = SENDING; count++; // send a packet } /* Fixed Version */ uint8_t oldState; atomic { oldState = state; if (state == IDLE) { state = SENDING; } if (oldState == IDLE) { count++; // send a packet }

24 April 15, 2005TinyOS: A Component Based OSSlide 24 of 27 Compiler Optimization Uses component model restrictions:  Eliminate unreachable code  Inline small functions Application Code SizeCode Reduction InlinedNoninlined Surge 147941698412% Maté 25040274589% TinyDB 649107172410%

25 April 15, 2005TinyOS: A Component Based OSSlide 25 of 27 Support Functions TinyOS Simulator /*====== Core mote modes =============*/ DBG_BOOT =DBG_MODE(0),/* the boot sequence*/ DBG_CLOCK =DBG_MODE(1),/* clock*/ DBG_TASK =DBG_MODE(2),/* task stuff*/ DBG_SCHED =DBG_MODE(3),/* switch, scheduling*/ DBG_SENSOR =DBG_MODE(4),/* sensor readings*/ DBG_LED =DBG_MODE(5),/* LEDs*/ DBG_CRYPTO =DBG_MODE(6),/* Cryptography/security*/ /*====== Networking modes ============*/ DBG_ROUTE =DBG_MODE(7),/* network routing*/ DBG_AM =DBG_MODE(8),/* Active Messages*/ DBG_CRC =DBG_MODE(9),/* packet CRC stuff*/ DBG_PACKET =DBG_MODE(10),/* Packet level stuff */ DBG_ENCODE =DBG_MODE(11), /* Radio encoding/decoding*/ DBG_RADIO =DBG_MODE(12),/* radio bits*/

26 April 15, 2005TinyOS: A Component Based OSSlide 26 of 27 Conclusions nesC implements TinyOS concurrency and component models effectively ↑ nesC also provides compile time optimizations and race condition detection ↑ Component swapping ↑ TOSSIM and TinyViz support functions ↑ Rapidly changing hardware ↓ Everyone knows C ↑

27 April 15, 2005TinyOS: A Component Based OSSlide 27 of 27 Conclusions TinyOS provides great interface for distributed applications ↑ Not perfect for all applications ↓  18 pages of code to blink 1 LED?


Download ppt "April 15, 2005TinyOS: A Component Based OSPage 1 of 27 TinyOS A Component-Based Operating System for Networked Embedded Systems Tom Bush Graduate College."

Similar presentations


Ads by Google