logging in or signing up 2 tinyos CoolDude26 Download Post to : URL : Related Presentations : Share Add to Flag Embed Email Send to Blogs and Networks Add to Channel Uploaded from authorPOINTLite Insert YouTube videos in PowerPont slides with aS Desktop Copy embed code: (To copy code, click on the text box) Embed: URL: Thumbnail: WordPress Embed Customize Embed The presentation is successfully added In Your Favorites. Views: 675 Category: Entertainment License: All Rights Reserved Like it (0) Dislike it (0) Added: October 29, 2007 This Presentation is Public Favorites: 0 Presentation Description No description available. Comments Posting comment... By: Shoaibmansoori32 (28 month(s) ago) Very good Saving..... Post Reply Close Saving..... Edit Comment Close Premium member Presentation Transcript Programming TinyOS: Programming TinyOS David Culler, Phil Levis, Rob Szewczyk, Joe Polastre University of California, Berkeley Intel Research Berkeley Characteristics of Network Sensors: Characteristics of Network Sensors Small physical size and low power consumption Concurrency-intensive operation multiple flows, not wait-command-respond Limited Physical Parallelism and Controller Hierarchy primitive direct-to-device interface Asynchronous and synchronous devices Diversity in Design and Usage application specific, not general purpose huge device variation => efficient modularity => migration across HW/SW boundary Robust Operation numerous, unattended, critical => narrow interfacesA Operating System for Tiny Devices?: A Operating System for Tiny Devices? Traditional approaches command processing loop (wait request, act, respond) monolithic event processing bring full thread/socket posix regime to platform Alternative provide framework for concurrency and modularity never poll, never block interleaving flows, events, energy management => allow appropriate abstractions to emerge Tiny OS Concepts: Tiny OS Concepts Scheduler + Graph of Components constrained two-level scheduling model: threads + events Component: Commands, Event Handlers Frame (storage) Tasks (concurrency) Constrained Storage Model frame per component, shared stack, no heap Very lean multithreading Efficient Layering Messaging Component init Power(mode) TX_packet(buf) TX_packet_done (success) RX_packet_done (buffer) Internal State init power(mode) send_msg(addr, type, data) internal thread Commands EventsApplication = Graph of Components: Application = Graph of Components RFM Radio byte Radio Packet UART Serial Packet ADC Temp photo Active Messages clocks bit byte packet Route map router sensor appln application HW SW Example: ad hoc, multi-hop routing of photo sensor readings 3450 B code 226 B data Graph of cooperating state machines on shared stackTOS Execution Model: TOS Execution Model commands request action ack/nack at every boundary call cmd or post task events notify occurrence HW intrpt at lowest level may signal events call cmds post tasks Tasks provide logical concurrency preempted by events Migration of HW/SW boundary event-driven bit-pump event-driven byte-pump event-driven packet-pump message-event driven active message application comp encode/decode crc data processingDynamics of Events and Threads: Dynamics of Events and Threads bit event filtered at byte layer bit event => end of byte => end of packet => end of msg send thread posted to start send next message radio takes clock events to detect recvProgramming TinyOS: Programming TinyOS TinyOS 1.0 is written in an extension of C, called nesC Applications are too! just additional components composed with the OS components Provides syntax for TinyOS concurrency and storage model commands, events, tasks local frame variable Rich Compositional Support separation of definition and linkage robustness through narrow interfaces and reuse interpositioning Whole system analysis and optimizationEvent-Driven Sensor Access Pattern: Event-Driven Sensor Access Pattern clock event handler initiates data collection sensor signals data ready event data event handler calls output command device sleeps or handles other activity while waiting conservative send/ack at component boundary command result_t StdControl.start() { return call Timer.start(TIMER_REPEAT, 200); } event result_t Timer.fired() { return call sensor.getData(); } event result_t sensor.dataReady(uint16_t data) { display(data) return SUCCESS; } SENSE Timer Photo LED TinyOS Commands and Events: TinyOS Commands and Events { ... status = call CmdName(args) ... } command CmdName(args) { ... return status; } { ... status = signal EvtName(args) ... } event EvtName)(args) { ... return status; }TinyOS Execution Contexts: TinyOS Execution Contexts Events generated by interrupts preempt tasks Tasks do not preempt tasks Both essential process state transitions TASKS: TASKS provide concurrency internal to a component longer running operations are preempted by events able to perform operations beyond event context may call commands may signal events not preempted by tasks { ... post TskName(); ... } task void TskName { ... }Typical application use of tasks: Typical application use of tasks event driven data acquisition schedule task to do computational portion event result_t sensor.dataReady(uint16_t data) { putdata(data); post processData(); return SUCCESS; } task void processData() { int16_t i, sum=0; for (i=0; i ‹ maxdata; i++) sum += (rdata[i] ›› 7); display(sum ›› shiftdata); } 128 Hz sampling rate simple FIR filter dynamic software tuning for centering the magnetometer signal (1208 bytes) digital control of analog, not DSP ADC (196 bytes)Tasks in low-level operation: Tasks in low-level operation transmit packet send command schedules task to calculate CRC task initiated byte-level data pump events keep the pump flowing receive packet receive event schedules task to check CRC task signals packet ready if OK byte-level tx/rx task scheduled to encode/decode each complete byte must take less time that byte data transfer i2c component i2c bus has long suspensive operations tasks used to create split-phase interface events can procede during bus transactionsExample: Radio Byte Operation: Example: Radio Byte Operation Pipelines transmission – transmits single byte while encoding next byte Trades 1 byte of buffering for easy deadline Separates high level latencies from low level real-time requirements Encoding Task must complete before byte transmission completes Decode must complete before next byte arrives Encode Task Bit transmission Byte 1 Byte 2 RFM Bits Byte 2 Byte 1 Byte 3 Byte 3 Byte 4 start … Hardware accelerators in MICA eliminate bit pumpsTask Scheduling: Task Scheduling Currently simple fifo scheduler Bounded number of pending tasks When idle, shuts down node except clock Uses non-blocking task queue data structure Simple event-driven structure + control over complete application/system graph instead of complex task priorities and IPCTiny Active Messages: Tiny Active Messages Sending Declare buffer storage in a frame Request Transmission Name a handler Handle Completion signal Receiving Declare a handler Firing a handler automatic behaves like any other event Buffer management strict ownership exchange tx: done event => reuse rx: must rtn a buffer Sending a message: Sending a message Refuses to accept command if buffer is still full or network refuses to accept send command User component provide structured msg storageSend done event: Send done event Send done event fans out to all potential senders Originator determined by match free buffer on success, retry or fail on failure Others use the event to schedule pending communication event result_t IntOutput.sendDone(TOS_MsgPtr msg, result_t success) { if (pending && msg == &data) { pending = FALSE; signal IntOutput.outputComplete(success); } return SUCCESS; } }Receive Event: Receive Event Active message automatically dispatched to associated handler knows the format, no run-time parsing performs action on message event Must return free buffer to the system typically the incoming buffer if processing complete event TOS_MsgPtr ReceiveIntMsg.receive(TOS_MsgPtr m) { IntMsg *message = (IntMsg *)m->data; call IntOutput.output(message->val); return m; }Maintaining Scheduling Agility: Maintaining Scheduling Agility Need logical concurrency at many levels of the graph While meeting hard timing constraints sample the radio in every bit window Retain event-driven structure throughout application Tasks extend processing outside event window All operations are non-blockingThe Complete Application: SecDedEncode The Complete Application RadioCRCPacket UART UARTnoCRCPacket ADC phototemp AMStandard ClockC bit byte packet SenseToRfm HW SW IntToRfm MicaHighSpeedRadioM RandomLFSR SPIByteFIFO SlavePin noCRCPacket Timer photo generic comm Composition: Composition A component specifies a set of interfaces by which it is connected to other components provides a set of interfaces to others uses a set of interfaces provided by others Interfaces are bi-directional include commands and events Interface methods are the external namespace of the component Timer Component StdControl Timer Clock provides uses provides interface StdControl; interface Timer: uses interface ClockComponents: Components Modules provide code that implements one or more interfaces and internal behavior Configurations link together components to yield new component Interface logically related set of commands and events StdControl.nc interface StdControl { command result_t init(); command result_t start(); command result_t stop(); } Clock.nc interface Clock { command result_t setRate(char interval, char scale); event result_t fire(); }Example top level configuration: Example top level configuration configuration SenseToRfm { // this module does not provide any interface } implementation { components Main, SenseToInt, IntToRfm, ClockC, Photo as Sensor; Main.StdControl -> SenseToInt; Main.StdControl -> IntToRfm; SenseToInt.Clock -> ClockC; SenseToInt.ADC -> Sensor; SenseToInt.ADCControl -> Sensor; SenseToInt.IntOutput -> IntToRfm; } SenseToInt Main StdControl ADCControl IntOutput Clock ADC Nested configuration: Nested configuration includes IntMsg; configuration IntToRfm { provides { interface IntOutput; interface StdControl; } } implementation { components IntToRfmM, GenericComm as Comm; IntOutput = IntToRfmM; StdControl = IntToRfmM; IntToRfmM.Send -> Comm.SendMsg[AM_INTMSG]; IntToRfmM.SubControl -> Comm; } IntToRfmM GenericComm StdControl IntOutput SubControl SendMsg[AM_INTMSG];IntToRfm Module: IntToRfm Module includes IntMsg; module IntToRfmM { uses { interface StdControl as SubControl; interface SendMsg as Send; } provides { interface IntOutput; interface StdControl; } } implementation { bool pending; struct TOS_Msg data; command result_t StdControl.init() { pending = FALSE; return call SubControl.init(); } command result_t StdControl.start() { return call SubControl.start(); } command result_t StdControl.stop() { return call SubControl.stop(); } command result_t IntOutput.output(uint16_t value) { ... if (call Send.send(TOS_BCAST_ADDR, sizeof(IntMsg), &data) return SUCCESS; ... } event result_t Send.sendDone(TOS_MsgPtr msg, result_t success) { ... } }A Multihop Routing Example: A Multihop Routing ExampleSample Components: Sample Components Communication Radio, UART, I2C of various flavors Timing Timer, Clock Sensors voltage, photo, light Busses i2c, SPI Storage eeprom, logger Energy management snooze Components => Services: Components => Services Multihop Routing Time synchronization Identity, Discovery ...Supporting HW evolution: Supporting HW evolution Distribution broken into apps: top-level applications lib: shared application components system: hardware independent system components platform: hardware dependent system components includes HPLs and hardware.h Component design so HW and SW look the same example: temp component may abstract particular channel of ADC on the microcontroller may be a SW i2C protocol to a sensor board with digital sensor or ADC HW/SW boundary can move up and down with minimal changesScalable Simulation Environment: Scalable Simulation Environment target platform: TOSSIM whole application compiled for host native instruction set event-driven execution mapped into event-driven simulator machinery storage model mapped to thousands of virtual nodes radio model and environmental model plugged in bit-level fidelity Sockets = basestation Complete application including GUISimulation Scaling: Simulation Scaling Current Areas of Development: Current Areas of Development Security Safe Concurrency atomicity support automatic race detection Abstract ComponentsWhere to go for more?: Where to go for more? http://www.tinyos.net/tos/ http://sourceforge.net/projects/tinyos/ Jason Hill, Robert Szewczyk, Alec Woo, Seth Hollar, David Culler, Kristofer Pister. System architecture directions for network sensors. ASPLOS 2000. David E. Culler, Jason Hill, Philip Buonadonna, Robert Szewczyk, and Alec Woo. A Network-Centric Approach to Embedded Software for Tiny Devices. EMSOFT 2001. You do not have the permission to view this presentation. In order to view it, please contact the author of the presentation.
2 tinyos CoolDude26 Download Post to : URL : Related Presentations : Share Add to Flag Embed Email Send to Blogs and Networks Add to Channel Uploaded from authorPOINTLite Insert YouTube videos in PowerPont slides with aS Desktop Copy embed code: (To copy code, click on the text box) Embed: URL: Thumbnail: WordPress Embed Customize Embed The presentation is successfully added In Your Favorites. Views: 675 Category: Entertainment License: All Rights Reserved Like it (0) Dislike it (0) Added: October 29, 2007 This Presentation is Public Favorites: 0 Presentation Description No description available. Comments Posting comment... By: Shoaibmansoori32 (28 month(s) ago) Very good Saving..... Post Reply Close Saving..... Edit Comment Close Premium member Presentation Transcript Programming TinyOS: Programming TinyOS David Culler, Phil Levis, Rob Szewczyk, Joe Polastre University of California, Berkeley Intel Research Berkeley Characteristics of Network Sensors: Characteristics of Network Sensors Small physical size and low power consumption Concurrency-intensive operation multiple flows, not wait-command-respond Limited Physical Parallelism and Controller Hierarchy primitive direct-to-device interface Asynchronous and synchronous devices Diversity in Design and Usage application specific, not general purpose huge device variation => efficient modularity => migration across HW/SW boundary Robust Operation numerous, unattended, critical => narrow interfacesA Operating System for Tiny Devices?: A Operating System for Tiny Devices? Traditional approaches command processing loop (wait request, act, respond) monolithic event processing bring full thread/socket posix regime to platform Alternative provide framework for concurrency and modularity never poll, never block interleaving flows, events, energy management => allow appropriate abstractions to emerge Tiny OS Concepts: Tiny OS Concepts Scheduler + Graph of Components constrained two-level scheduling model: threads + events Component: Commands, Event Handlers Frame (storage) Tasks (concurrency) Constrained Storage Model frame per component, shared stack, no heap Very lean multithreading Efficient Layering Messaging Component init Power(mode) TX_packet(buf) TX_packet_done (success) RX_packet_done (buffer) Internal State init power(mode) send_msg(addr, type, data) internal thread Commands EventsApplication = Graph of Components: Application = Graph of Components RFM Radio byte Radio Packet UART Serial Packet ADC Temp photo Active Messages clocks bit byte packet Route map router sensor appln application HW SW Example: ad hoc, multi-hop routing of photo sensor readings 3450 B code 226 B data Graph of cooperating state machines on shared stackTOS Execution Model: TOS Execution Model commands request action ack/nack at every boundary call cmd or post task events notify occurrence HW intrpt at lowest level may signal events call cmds post tasks Tasks provide logical concurrency preempted by events Migration of HW/SW boundary event-driven bit-pump event-driven byte-pump event-driven packet-pump message-event driven active message application comp encode/decode crc data processingDynamics of Events and Threads: Dynamics of Events and Threads bit event filtered at byte layer bit event => end of byte => end of packet => end of msg send thread posted to start send next message radio takes clock events to detect recvProgramming TinyOS: Programming TinyOS TinyOS 1.0 is written in an extension of C, called nesC Applications are too! just additional components composed with the OS components Provides syntax for TinyOS concurrency and storage model commands, events, tasks local frame variable Rich Compositional Support separation of definition and linkage robustness through narrow interfaces and reuse interpositioning Whole system analysis and optimizationEvent-Driven Sensor Access Pattern: Event-Driven Sensor Access Pattern clock event handler initiates data collection sensor signals data ready event data event handler calls output command device sleeps or handles other activity while waiting conservative send/ack at component boundary command result_t StdControl.start() { return call Timer.start(TIMER_REPEAT, 200); } event result_t Timer.fired() { return call sensor.getData(); } event result_t sensor.dataReady(uint16_t data) { display(data) return SUCCESS; } SENSE Timer Photo LED TinyOS Commands and Events: TinyOS Commands and Events { ... status = call CmdName(args) ... } command CmdName(args) { ... return status; } { ... status = signal EvtName(args) ... } event EvtName)(args) { ... return status; }TinyOS Execution Contexts: TinyOS Execution Contexts Events generated by interrupts preempt tasks Tasks do not preempt tasks Both essential process state transitions TASKS: TASKS provide concurrency internal to a component longer running operations are preempted by events able to perform operations beyond event context may call commands may signal events not preempted by tasks { ... post TskName(); ... } task void TskName { ... }Typical application use of tasks: Typical application use of tasks event driven data acquisition schedule task to do computational portion event result_t sensor.dataReady(uint16_t data) { putdata(data); post processData(); return SUCCESS; } task void processData() { int16_t i, sum=0; for (i=0; i ‹ maxdata; i++) sum += (rdata[i] ›› 7); display(sum ›› shiftdata); } 128 Hz sampling rate simple FIR filter dynamic software tuning for centering the magnetometer signal (1208 bytes) digital control of analog, not DSP ADC (196 bytes)Tasks in low-level operation: Tasks in low-level operation transmit packet send command schedules task to calculate CRC task initiated byte-level data pump events keep the pump flowing receive packet receive event schedules task to check CRC task signals packet ready if OK byte-level tx/rx task scheduled to encode/decode each complete byte must take less time that byte data transfer i2c component i2c bus has long suspensive operations tasks used to create split-phase interface events can procede during bus transactionsExample: Radio Byte Operation: Example: Radio Byte Operation Pipelines transmission – transmits single byte while encoding next byte Trades 1 byte of buffering for easy deadline Separates high level latencies from low level real-time requirements Encoding Task must complete before byte transmission completes Decode must complete before next byte arrives Encode Task Bit transmission Byte 1 Byte 2 RFM Bits Byte 2 Byte 1 Byte 3 Byte 3 Byte 4 start … Hardware accelerators in MICA eliminate bit pumpsTask Scheduling: Task Scheduling Currently simple fifo scheduler Bounded number of pending tasks When idle, shuts down node except clock Uses non-blocking task queue data structure Simple event-driven structure + control over complete application/system graph instead of complex task priorities and IPCTiny Active Messages: Tiny Active Messages Sending Declare buffer storage in a frame Request Transmission Name a handler Handle Completion signal Receiving Declare a handler Firing a handler automatic behaves like any other event Buffer management strict ownership exchange tx: done event => reuse rx: must rtn a buffer Sending a message: Sending a message Refuses to accept command if buffer is still full or network refuses to accept send command User component provide structured msg storageSend done event: Send done event Send done event fans out to all potential senders Originator determined by match free buffer on success, retry or fail on failure Others use the event to schedule pending communication event result_t IntOutput.sendDone(TOS_MsgPtr msg, result_t success) { if (pending && msg == &data) { pending = FALSE; signal IntOutput.outputComplete(success); } return SUCCESS; } }Receive Event: Receive Event Active message automatically dispatched to associated handler knows the format, no run-time parsing performs action on message event Must return free buffer to the system typically the incoming buffer if processing complete event TOS_MsgPtr ReceiveIntMsg.receive(TOS_MsgPtr m) { IntMsg *message = (IntMsg *)m->data; call IntOutput.output(message->val); return m; }Maintaining Scheduling Agility: Maintaining Scheduling Agility Need logical concurrency at many levels of the graph While meeting hard timing constraints sample the radio in every bit window Retain event-driven structure throughout application Tasks extend processing outside event window All operations are non-blockingThe Complete Application: SecDedEncode The Complete Application RadioCRCPacket UART UARTnoCRCPacket ADC phototemp AMStandard ClockC bit byte packet SenseToRfm HW SW IntToRfm MicaHighSpeedRadioM RandomLFSR SPIByteFIFO SlavePin noCRCPacket Timer photo generic comm Composition: Composition A component specifies a set of interfaces by which it is connected to other components provides a set of interfaces to others uses a set of interfaces provided by others Interfaces are bi-directional include commands and events Interface methods are the external namespace of the component Timer Component StdControl Timer Clock provides uses provides interface StdControl; interface Timer: uses interface ClockComponents: Components Modules provide code that implements one or more interfaces and internal behavior Configurations link together components to yield new component Interface logically related set of commands and events StdControl.nc interface StdControl { command result_t init(); command result_t start(); command result_t stop(); } Clock.nc interface Clock { command result_t setRate(char interval, char scale); event result_t fire(); }Example top level configuration: Example top level configuration configuration SenseToRfm { // this module does not provide any interface } implementation { components Main, SenseToInt, IntToRfm, ClockC, Photo as Sensor; Main.StdControl -> SenseToInt; Main.StdControl -> IntToRfm; SenseToInt.Clock -> ClockC; SenseToInt.ADC -> Sensor; SenseToInt.ADCControl -> Sensor; SenseToInt.IntOutput -> IntToRfm; } SenseToInt Main StdControl ADCControl IntOutput Clock ADC Nested configuration: Nested configuration includes IntMsg; configuration IntToRfm { provides { interface IntOutput; interface StdControl; } } implementation { components IntToRfmM, GenericComm as Comm; IntOutput = IntToRfmM; StdControl = IntToRfmM; IntToRfmM.Send -> Comm.SendMsg[AM_INTMSG]; IntToRfmM.SubControl -> Comm; } IntToRfmM GenericComm StdControl IntOutput SubControl SendMsg[AM_INTMSG];IntToRfm Module: IntToRfm Module includes IntMsg; module IntToRfmM { uses { interface StdControl as SubControl; interface SendMsg as Send; } provides { interface IntOutput; interface StdControl; } } implementation { bool pending; struct TOS_Msg data; command result_t StdControl.init() { pending = FALSE; return call SubControl.init(); } command result_t StdControl.start() { return call SubControl.start(); } command result_t StdControl.stop() { return call SubControl.stop(); } command result_t IntOutput.output(uint16_t value) { ... if (call Send.send(TOS_BCAST_ADDR, sizeof(IntMsg), &data) return SUCCESS; ... } event result_t Send.sendDone(TOS_MsgPtr msg, result_t success) { ... } }A Multihop Routing Example: A Multihop Routing ExampleSample Components: Sample Components Communication Radio, UART, I2C of various flavors Timing Timer, Clock Sensors voltage, photo, light Busses i2c, SPI Storage eeprom, logger Energy management snooze Components => Services: Components => Services Multihop Routing Time synchronization Identity, Discovery ...Supporting HW evolution: Supporting HW evolution Distribution broken into apps: top-level applications lib: shared application components system: hardware independent system components platform: hardware dependent system components includes HPLs and hardware.h Component design so HW and SW look the same example: temp component may abstract particular channel of ADC on the microcontroller may be a SW i2C protocol to a sensor board with digital sensor or ADC HW/SW boundary can move up and down with minimal changesScalable Simulation Environment: Scalable Simulation Environment target platform: TOSSIM whole application compiled for host native instruction set event-driven execution mapped into event-driven simulator machinery storage model mapped to thousands of virtual nodes radio model and environmental model plugged in bit-level fidelity Sockets = basestation Complete application including GUISimulation Scaling: Simulation Scaling Current Areas of Development: Current Areas of Development Security Safe Concurrency atomicity support automatic race detection Abstract ComponentsWhere to go for more?: Where to go for more? http://www.tinyos.net/tos/ http://sourceforge.net/projects/tinyos/ Jason Hill, Robert Szewczyk, Alec Woo, Seth Hollar, David Culler, Kristofer Pister. System architecture directions for network sensors. ASPLOS 2000. David E. Culler, Jason Hill, Philip Buonadonna, Robert Szewczyk, and Alec Woo. A Network-Centric Approach to Embedded Software for Tiny Devices. EMSOFT 2001.