03.08.2013 Views

Design and Implementation of TinyGALS: A Programming Model for ...

Design and Implementation of TinyGALS: A Programming Model for ...

Design and Implementation of TinyGALS: A Programming Model for ...

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

uns in a single thread <strong>of</strong> execution (single stack), which may be interrupted by the hard-<br />

ware. Reentrant code can have multiple simultaneous, interleaved, or nested invocations<br />

which will not interfere with each other. In this section, we assume that interrupts are not<br />

reentrant, but that an interrupt is masked while servicing it (interleaved invocations are dis-<br />

abled). However, other interrupts may occur while servicing the interrupt. 7 There are no<br />

other sources <strong>of</strong> preemption other than hardware interrupts. When using components in<br />

which interrupts are enabled in the interrupt h<strong>and</strong>ler, we must take special care in placing<br />

constraints on what constitutes a valid configuration <strong>of</strong> components within a module in<br />

order to avoid unexpected reentrancy, which may lead to race conditions <strong>and</strong> other nonde-<br />

terminacy issues. We assume the existence <strong>of</strong> a clock, which is used to order events.<br />

2.3.2 <strong>TinyGALS</strong> Components<br />

There are three cases in which a component C may begin execution: (1) an interrupt from<br />

the hardware that C encapsulates, (2) an event arrives on the module input port linked to<br />

one <strong>of</strong> the interface methods <strong>of</strong> C, or (3) another component calls one <strong>of</strong> the interface meth-<br />

ods <strong>of</strong> C. In the first case, the component is a source component <strong>and</strong> when activated by a<br />

hardware interrupt, the corresponding interrupt service routine is run. Source components<br />

do not connect to any module input ports. In the second case, the component is a triggered<br />

component, <strong>and</strong> the event triggers the execution <strong>of</strong> the method (in ACCEPT SC) to which<br />

the input port is linked. Both source components <strong>and</strong> triggered components may call other<br />

components (via the methods in USESC), which results in the third case, where the com-<br />

ponent is a called component. Once activated, a component executes to completion. That<br />

7 The avr-gcc compiler <strong>for</strong> the Atmel AVR microcontroller on the MICA motes provides two macros <strong>for</strong><br />

writing user-defined interrupt service routines (locations specified in the interrupt vector table). The SIGNAL<br />

macro indicates that the specified function is a signal h<strong>and</strong>ler; interrupts are disabled inside the function. The<br />

INTERRUPT macro indicates that the specified function is an interrupt h<strong>and</strong>ler; interrupts are enabled inside<br />

the function. In the TinyOS v0.6.1 distribution, the following components use the INTERRUPT macro on the<br />

MICA motes: CLOCK, RF PROXIMITY, TIMESTAMP, LOGGER, UART (transmission only); the following<br />

components re-enable interrupts inside <strong>of</strong> the SIGNAL macro on the MICA motes: MIC <strong>and</strong> ADC.<br />

14

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!