Introduction to TinyOS. Faster, Smaller, Numerous Moore’s Law –“Stuff” (transistors, etc) doubling every 1-2 years Bell’s Law –New computing class every.

Slides:



Advertisements
Similar presentations
Telos Fourth Generation WSN Platform
Advertisements

Chorus and other Microkernels Presented by: Jonathan Tanner and Brian Doyle Articles By: Jon Udell Peter D. Varhol Dick Pountain.
The nesc Language: A Holistic Approach to Networked Embedded Systems David Gay, Philip Levis, Robert von Behren, Matt Welsh, Eric Brewer, David Culler.
Sensor Network Platforms and Tools
Overview: Chapter 7  Sensor node platforms must contend with many issues  Energy consumption  Sensing environment  Networking  Real-time constraints.
TinyOS. Software Challenges - TinyOS Power efficient –Put microcontroller and radio to sleep Small memory footprint –Non-preemptable.
Lecture Objectives: 1)Explain the limitations of flash memory. 2)Define wear leveling. 3)Define the term IO Transaction 4)Define the terms synchronous.
A Dynamic Operating System for Sensor Nodes (SOS) Source:The 3 rd International Conference on Mobile Systems, Applications, and Service (MobiSys 2005)
Chapter 7 Protocol Software On A Conventional Processor.
Chapter 13 Embedded Systems
The Mote Revolution: Low Power Wireless Sensor Network Devices
Chapter 13 Embedded Systems Patricia Roy Manatee Community College, Venice, FL ©2008, Prentice Hall Operating Systems: Internals and Design Principles,
ECE 526 – Network Processing Systems Design Software-based Protocol Processing Chapter 7: D. E. Comer.
Contiki A Lightweight and Flexible Operating System for Tiny Networked Sensors Presented by: Jeremy Schiff.
How to Code on TinyOS Xufei Mao Advisor: Dr. Xiang-yang Li CS Dept. IIT.
Jason Hill, Robert Szewczyk, Alec Woo Spring 2000 TinyOS Operating System for Networked Sensors Networked SensorsSystem Structure Composing Components.
Sample Project Ideas KD Kang. Project Idea 1: Real-time task scheduling in TinyOS EDF in TinyOS 2.x –Description is available at
1: Operating Systems Overview
I/O Hardware n Incredible variety of I/O devices n Common concepts: – Port – connection point to the computer – Bus (daisy chain or shared direct access)
The Mote Revolution: Low Power Wireless Sensor Network Devices
Chapter 13 Embedded Systems
2008EECS Embedded Network Programming nesC, TinyOS, Networking, Microcontrollers Jonathan Hui University of California, Berkeley.
Figure 1.1 Interaction between applications and the operating system.
Introduction to TinyOS. Networking Open Experimental Platform Small microcontroller 8 kB code 512 B data Simple, low-power radio 10 kbps ASK EEPROM (32.
1 EE249 Discussion System Architecture Directions for Networked Sensors (J. Hill, et al) Presented By: Sarah Bergbreiter EE249 Discussion Section October.
Chapter 13 Embedded Operating Systems Eighth Edition By William Stallings Operating Systems: Internals and Design Principles.
Chapter 13: I/O Systems I/O Hardware Application I/O Interface
I/O Tanenbaum, ch. 5 p. 329 – 427 Silberschatz, ch. 13 p
1 Software Development Infrastructure for Sensor Networks  Operating systems ( TinyOS )  Resource (device) management  Basic primitives  Protocols.
A System Architecture for Networked Sensors Jason Hill, Robert Szewczyk, Alec Woo, Seth Hollar, David Culler, Kris Pister
By: R Jayampathi Sampath
April 15, 2005TinyOS: A Component Based OSPage 1 of 27 TinyOS A Component-Based Operating System for Networked Embedded Systems Tom Bush Graduate College.
TinyOS. Learning Objectives Understand TinyOS – the dominant open source operating systems for WSN –Hardware abstraction architecture (HAA) –TinyOS architecture.
LOGO OPERATING SYSTEM Dalia AL-Dabbagh
Operating System Review September 10, 2012Introduction to Computer Security ©2004 Matt Bishop Slide #1-1.
TinyOS By Morgan Leider CS 411 with Mike Rowe with Mike Rowe.
Hardware Definitions –Port: Point of connection –Bus: Interface Daisy Chain (A=>B=>…=>X) Shared Direct Device Access –Controller: Device Electronics –Registers:
CHAPTER 3 TOP LEVEL VIEW OF COMPUTER FUNCTION AND INTERCONNECTION
Korea Advanced Institute of Science and Technology Active Sensor Networks(Mate) (Published by Philip Levis, David Gay, and David Culler in NSDI 2005) 11/11/09.
Vishal Jain, TinyOS Design Viewpoint “TinyOS” Design Viewpoint.
Lecture 3 Process Concepts. What is a Process? A process is the dynamic execution context of an executing program. Several processes may run concurrently,
Dhanshree Nimje Smita Khartad
System Architecture Directions for Networked Sensors Jason Hill, Robert Szewczyk, Alec Woo, Seth Hollar, David Culler, Kris Pister Presented by Yang Zhao.
Simulation of Distributed Application and Protocols using TOSSIM Valliappan Annamalai.
Nano-RK: An Energy-Aware Resource Centric RTOS for Sensor Networks Anand Eswaran, Anthony Rowe and Raj Rajkumar Presented by: Ravi Ramaseshan.
Computers Operating System Essentials. Operating Systems PROGRAM HARDWARE OPERATING SYSTEM.
I/O Computer Organization II 1 Interconnecting Components Need interconnections between – CPU, memory, I/O controllers Bus: shared communication channel.
System Architecture Directions for Networked Sensors Jason Hill, Robert Szewczyk, Alec Woo, Seth Hollar, David Culler, Kris Pister Presenter: James.
Overview of Operating Systems Introduction to Operating Systems: Module 0.
Xiong Junjie Node-level debugging based on finite state machine in wireless sensor networks.
WSN Software Platforms - concepts Vinod Kulathumani Lecture uses some slides from tutorials prepared by authors of these platforms.
Chapter 13 – I/O Systems (Pgs ). Devices  Two conflicting properties A. Growing uniformity in interfaces (both h/w and s/w): e.g., USB, TWAIN.
1 VxWorks 5.4 Group A3: Wafa’ Jaffal Kathryn Bean.
TinyOS Sandeep Gupta. Operating System (OS) What is an OS? Main functions  Process management  Memory management  Resource management Traditional OSs.
System Architecture Directions for Networked Sensors.
Slides created by: Professor Ian G. Harris Operating Systems  Allow the processor to perform several tasks at virtually the same time Ex. Web Controlled.
1 Device Controller I/O units typically consist of A mechanical component: the device itself An electronic component: the device controller or adapter.
Unit - I Real Time Operating System. Content : Operating System Concepts Real-Time Tasks Real-Time Systems Types of Real-Time Tasks Real-Time Operating.
Embedded Real-Time Systems Processing interrupts Lecturer Department University.
CSCI/CMPE 4334 Operating Systems Review: Exam 1 1.
1 Chapter 2: Operating-System Structures Services Interface provided to users & programmers –System calls (programmer access) –User level access to system.
Why does it need? [USN] ( 주 ) 한백전자 Background Wireless Sensor Network (WSN)  Relationship between Sensor and WSN Individual sensors are very limited.
Software Architecture of Sensors. Hardware - Sensor Nodes Sensing: sensor --a transducer that converts a physical, chemical, or biological parameter into.
TinyOS and nesC. Outline ● Wireless sensor networks and TinyOS ● Networked embedded system C (nesC) – Components – Interfaces – Concurrency model – Tool.
Introduction to Operating Systems Concepts
INTRODUCTION TO WIRELESS SENSOR NETWORKS
CS703 - Advanced Operating Systems
Chapter 13: I/O Systems.
Modeling Event-Based Systems in Ptolemy II EE249 Project Status Report
Chapter 13: I/O Systems “The two main jobs of a computer are I/O and [CPU] processing. In many cases, the main job is I/O, and the [CPU] processing is.
Presentation transcript:

Introduction to TinyOS

Faster, Smaller, Numerous Moore’s Law –“Stuff” (transistors, etc) doubling every 1-2 years Bell’s Law –New computing class every 10 years year log (people per computer) Streaming Data to/from the Physical World Source: HotChips 2004

Mote Evolution Source: HotChips 2004

Design Principles Key to Low Duty Cycle Operation: –Sleep – majority of the time –Wakeup – quickly start processing –Active – minimize work & return to sleep Source: HotChips 2004

Sleep Majority of time, node is asleep –>99% Minimize sleep current through –Isolating and shutting down individual circuits –Using low power hardware Need RAM retention Run auxiliary hardware components from low speed oscillators (typically 32kHz) –Perform ADC conversions, DMA transfers, and bus operations while microcontroller core is stopped There’s wake-up overhead too Source: HotChips 2004

Reminder watt = voltage * amphere –Unit of power joule = watt * second –Unit of energy

Active Microcontroller –Fast processing, low active power –Avoid external oscillators Radio –High data rate, low power tradeoffs –Narrowband radios Low power, lower data rate, simple channel encoding, faster startup –Wideband radios More robust to noise, higher power, high data rates External Flash (stable storage) –Data logging, network code reprogramming, aggregation –High power consumption –Long writes Radio vs. Flash –250kbps radio sending 1 byte Energy : 1.5  J Duration : 32  s –Atmel flash writing 1 byte Energy : 3  J Duration : 78  s Source: HotChips 2004

Mica2 (AVR) –0.2 ms wakeup –30  W sleep –33 mW active –19 kbps Power Calculation Comparison Design for low power MicaZ (AVR) –0.2 ms wakeup –30  W sleep –33 mW active –250 kbps Telos (TI MSP) –0.006 ms wakeup –2  W sleep –3 mW active –250 kbps Report data once every 3 minutes with two AA batteries (<1% duty cycle) 328 days945 days453 days

Software challenges Power efficiency Small memory footprint Application specific Modularity Concurrency-intensive operations –Multiple, high-rate data flows (radio, sensor, actuator) Real-time –Real-time query and feedback control of physical world –Little memory for buffering: Data must be processed on the fly –TinyOS: No buffering in radio hw: deadline miss  data loss –TinyOS provides NO real-time guarantees! –EDF (Earliest Deadline First) scheduling supported in TinyOS 2.x

“General-Purpose” OS? MANY functionalities & programming APIs Protection between “untrusted” applications and kernel –Overhead for crossing kernel/user boundary & interrupt handling Multi-threaded architecture –Large number of threads  large memory –Context switch overhead I/O model –Blocking I/O: waste memory on blocked threads –Polling: waste CPU cycles and power Need a new OS architecture!

TinyOS Overview Application = scheduler + graph of components –Compiled into one executable Event-driven architecture Single shared stack No kernel/user space differentiation Communication ActuatingSensing Communication Application (User Components) Main (includes Scheduler) Hardware Abstractions

Traditional OS Architectures Problems Large memory & storage requirement Unnecessary and overkill functionality Address space isolation, complex I/O subsystem, UI Relatively high system overhead, e.g, context switch Require complex and power consuming hardware support VMI/O Scheduler Application 1 Application 2 Monolithic kernel HW NFSI/O Scheduler Application 1 Micro-kernel HW IPC VM

Desirable OS architecture Extremely small footprint Extremely low system overhead Extremely low power consumption

NO Kernel Direct hardware manipulation NO Process management Only one process on the fly NO Virtual memory Single linear physical address space NO Dynamic memory allocation Assigned at compile time NO Software signal or exception Function call Goal: to strip down memory size and system overhead. TinyOS Architecture Overview I/O COMM. ……. Scheduler TinyOS Application Component Application Component Application Component

TinyOS Architecture Overview Characteristics of TinyOS –No UI, power constrained –Application specific HW and SW –Multiple flows, concurrent bursts –Extremely passive vigilance (power saving ) –Tightly coupled with the application Mote Hardware ActuatingSensing Simplified TinyOS Architecture Active Message Communication Application (User Components) Main (includes Scheduler)

TinyOS component model Component has: –Frame: storage –Tasks: computation –Interface Command: request to lower-level components Event: deal with hardware events Frame: static storage model - compile time memory allocation (efficiency) Command and events are function calls (efficiency) Messaging Component Internal State Internal Tasks CommandsEvents

An Example Application RFM Radio byte (MAC) Radio Packet i2c Temp photo Messaging Layer clocks bit byte packet Routing Layer sensing application application HW SW ADC messaging routing

TinyOS Two-level Scheduling Tasks do computations –Non-preemptive FIFO scheduling –Bounded number of pending tasks Events handle concurrent data flows –Interrupts trigger lowest level events –Events preempt tasks, tasks do not –Events can signal events, call commands, or post tasks Hardware Interrupts events commands FIFO Tasks POST Preempt Time commands

Two-Level Scheduling Event and Task –Tasks cannot preempt other tasks or events –Single shared stack Used by both interrupts and function calls –Simple FIFO scheduler –Events can preempt a task –Events can preempt each other –When idle, scheduler shuts down the node except for clock

Event implementation Event is independent of FIFO scheduler. Lowest level events are supported directly by Hardware interrupt Software events propagate from lower level to upper level through function call

How to handle multiple data flows? Data are handled by –A sequence of non-blocking event/command (function calls) through the component graph –Post tasks for computations that are not “emergent” Preempting tasks to handle new data

How should network msg be handled? Socket/TCP/IP? –Too much memory for buffering and threads Data are buffered until application threads read it Application threads blocked until data is available –Transmit too many bits (sequence #, ack, re- transmission) –Tied with multi-threaded architecture TinyOS solution: Active Messages

Active Message Every message contains the name of an event handler Sender –Declare buffer storage in a frame –Name a handler –Request Transmission –Done - completion signal Receiver –The corresponding event handler invoked No blocked or waiting threads on the receiver Behaves like any other events Single buffering

Analysis and Evaluation Space, Power and Time

Code and Data Size Breakdown Scheduler: 178 Bytes code Totals: 3450 Bytes code 226 Bytes data

Time Breakdown

Power Breakdown…

Summary: TinyOS Component-based architecture –An application wires reusable components together in a customized way Tasks and event-driven concurrency –Tasks & events run to completion, but an event can preempt the execution of a task or an event –Tasks can’t preemt another task or event Split-phase operations (for non-blocking operations) –A command will return immediately and an event signals the completion

A quick look at nesC [O2] D. Gay, P. Levis, R. von Behren, M. Welsh, E. Brewer, and D. Culler, The nesC Language: A Holistic Approach to Networked Embedded Systems, ACM Conference on Programming Language Design and Implementation (PLDI), June 2003.The nesC Language: A Holistic Approach to Networked Embedded Systems,

Component A component provides and uses interfaces –The interfaces are the only point of access to the component An interface models some service, e.g., sending a msg The provider of a command implements the commands, while the user implements the events

Interface Bidirectional interfaces support split-phase execution

Component implementation Two types of components: modules & configurations Modules provide application code and implements one or more interfaces Configurations wire components together –Connect interfaces used by components to interfaces provided by others

Module Surge: Get a sensor reading and send a message every second

Configuration Wire TimerM and HWClock components together

Example: SurgeC configuration

Concurrency and Atomicity Asynchronous code (AC): reachable from at least one interrupt handler Synchronous code (SC): only reachable from tasks –Synchronous code is atomic w.r.t. other synchronous code Still potential races between AC and SC –Any update to shared state from AC –Any update to shared state from SC that is also updated from AC Solution: Race-Free Invariant –Any update to a shared variable is by SC or occurs inside an atomic section

atomic & norace Atomic –Disable interrupts –Atomic statements are not allowed to call commands or events –If a variable x is accessed by AC, any access of x outside of an atomic section is a compile time error –An atomic section should be short! norace –If a programmer knows a potential race is not an actual race, declare norace Disable interrupts Enable interrupts

Evaluation Tested for three TinyOS applications –Surge, Mate, TinyDB Core TinyOS consists of 172 components –108 modules & 64 configurations Group necessary components, via nesC’s bidirectional interfaces, for a specific application

Effect of inlining Impact of inlining on footprint and performance

Evaluation of TinyOS (and nesC) Small memory footprint  –Non-preemptable FIFO task scheduling Power efficient  –Put microcontroller and radio to sleep Efficient modularity  –Function call (event, command) interface between components Concurrency-intensive operations  –Event-driven architecture –Efficient interrupts/events handling (function calls, no user/kernel boundary) Real-time  –Non-preemptable FIFO task scheduling –No real-time guarantees or overload protection

Is TinyOS a silver bullet? Preemptive & deadline-driven scheduling? More support for power and energy-efficiency beyond OS? End-to-end timing guarantees? Reliable synchronization mechanism? –Most of things, e.g., I/O, are asynchronous Comeback of multithreading? –Most programmers are more used to multithreaded than event-driven programming –TinyThreads, TOSThreads

Other WSN Operating Systems Contiki –Events & Threads: Lightweight threading mechanism, called protothreads –Flash file system, called Coffee Mantis –Preemptive time-sliced multithreading –Synchronous I/O –Concurrency control, e.g., binary & counting semaphores Nano-RK –Reservation-based RTOS for WSNs –Fixed priority preemptive multitasking to meet real-time dedadlines –CPU and network bandwidth reservation –Socket-like abstractions and network scheduling and routing

RTEOS –Dual mode (kernel & user mode) –Application code checking at compile and runtime –Multithreading & support for POSIX 1003.b real-time scheduling LiteOS –Traditional Unix-like environment –Built-in hierarchical file system & a wireless Unix-like command shell –Kernel support for dynamic loading of multithreaded applications –LiteC++ (OO language using a subset of C++)

For a more comprehensive survey of WSN OS, talk to me to get a copy of: “Providing OS support for wireless sensor networks: challenges and approaches”, IEEE Communication Surveys and Tutorials. For more info about TinyOS, visit

Next Class At the beginning of the next class, submit one-page critique on the S-MAC paper: [M2] “An Energy-Efficient MAC Protocol for Wireless Sensor Networks”