Hi JD,

Here's my understanding of the way things work (hopefully someone more  
knowledgeable will correct me if I make any egregious errors).

At the hardware level, timer firings and radio reception produce  
interrupts that are handled as asynchronous events. These *will*  
preempt running synchronous code (unless an atomic block is active).  
However, the async event handlers usually post tasks which are later  
executed synchronously, and produce the higher-level sync events  
(Receive.receive and Timer.fired) that you are asking about. When  
execution of the async event handler terminates, control returns to  
the previously running sync code. Once that sync code has run to  
completion, the scheduler will move on to executing the next task, and  
will eventually get to executing the task that signals the higher- 
level sync event. This is the mechanism by which processing of actual  
hardware events, such as timer firings, is "put pending".

Here's a simplified example that's based on what happens in chips/ 
cc1000/CC1000SendReceiveP.nc, which provides the Receive interface.  
The async event HplCC1000Spi.dataReady eventually results in the  
signalPacketReceived() task being posted, and it is that task which  
later signals Receive.receive.


scheduler starts JDs_task()
    ...
     // Doing something in a sync context
    ...
     ------------> // Rx interrupt occurs - now into an async context
     ------------> async event HplCC1000Spi.dataReady
     ------------>    // Some immediate processing goes on here
     ------------>    post signalPacketReceived();
     ------------> end HplCC1000Spi.dataReady
    ...
    // More of JDs_task
    ...
end JDs_task()

scheduler starts signalPacketReceived()
    ...
    signal Receive.receive(); // Receive.receive event handler now  
gets executed
    ...
end signalPacketReceived()



Hope that helps!

Allan




On 6/12/2008, at 6:32 PM, JD wrote:

> Greetings,
>
> What would happen if scheduled timer fires (Timer.fired event) OR  
> message is rececied (Receive.receive event) while current _sync_  
> event is being executed?
>
> I believe following would happen,
> "Because current event is of type _sync_, it executes in _task_  
> context, which is non-preemptive in TinyOS, it will run to  
> completion while other events (e.g. timer and message received)  
> would be put pending (somehow). Once current event completes  
> execution, other pending events (based on scheduling policy) would  
> get executed."
>
> Please correct me if I'm wrong!!
>
>
> Thanks,
> JD

_______________________________________________
Tinyos-help mailing list
[email protected]
https://www.millennium.berkeley.edu/cgi-bin/mailman/listinfo/tinyos-help

Reply via email to