[Tinyos-help] can current task be pre-emptible by any _sync_ event?

Michael Schippling schip at santafe.edu
Mon Dec 8 10:13:00 PST 2008


I believe that all your assertions are correct, however it is
possible for the "higher level sync events" to be executed
directly from the interrupt handler and thus in interrupt context,
rather than from a new task.

But the take-away point is that tasks should not be long-running
because they may block events signaled from other "low level" tasks.

MS

Allan McInnes wrote:
> 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
> Tinyos-help at millennium.berkeley.edu
> https://www.millennium.berkeley.edu/cgi-bin/mailman/listinfo/tinyos-help

-- 
Platform: WinXP/Cygwin
TinyOS version: 1.x, Boomerang
Programmer: MIB510
Device(s): Mica2, MicaZ, Tmote
Sensor board: homebrew



More information about the Tinyos-help mailing list