【文章內(nèi)容簡介】
nchronous through threads is not possible. ? Solution : – Operations that are splitphase in hardware are splitphase in software. – Introduce interfaces that are bidirectional ADC S/W Start Sample Interrupts when plete Read the value SplitPhase Operations (Contd.) ADC Down call Start the operation Up call signals the operation is plete ? Down call mand ? Up call event SplitPhase Operations (Contd.) ? Splitphase interfaces enable a TinyOS ponent to easily start several operations at once and have them execute in parallel. ? splitphase operations can save memory. ? Ex: The mand is an example of a splitphase call. The user of the Timer inteface calls the mand, which returns immediately. Some time later (specified by the argument), the ponent providing Timer signals . In a system with blocking calls, a program might use sleep(): Interfaces with Arguments ? Interfaces can take types as arguments. ? wiring providers and users of interfaces that have type arguments, they types must match. ? used to enforce type checking. Module Implementation Tasks ? Consider magometer/ADC example: – depending on splitphase operations means that the magometer driver has to issue a callback. – it could just signal the event from within the call. – signaling an event from within a mand is generally a bad idea. ? might cause a very long call loop. ? corrupt memory and crash the program. – needs a way to schedule a function to be called later (like an interrupt). – can do this is with a task. Tasks (Contd.) ? Task – A module can post a task to the TinyOS scheduler. – doesn’t take any parameters. – A ponent posts a task to the TinyOS scheduler with the post keyword: post