Dear Manjunath and All,

Thanks so much for your clarification. However, I still have further
questions.

Looking back at the Blink application, we can see that BlinkC call three
commands in booted().
The startPeriodic is defined as synchronous. My concern here is how these 3
commands execute with the event booted(). Are they executing concurrently or
are they executing sequentially? or  are they scheduled in the scheduler
like a task?

Another question that bothers me a lot is during the execution of an nesC
application, do all tasks posted by all components share the same task
scheduler or does each component have their separate task scheduler?

Looking forward to your reply & many thanks in advance.

On Wed, Jan 6, 2010 at 5:17 PM, Manjunath Doddavenkatappa <
[email protected]> wrote:

> Hi,
>
>        Please have a look at /opt/tinyos-2.x/tos/system/RealMainP.nc. The
> execution starts from the main() and proceeds to initialize the system and
> then signals Boot.booted(). If you notice interrupts are enabled just before
> signalling Boot.booted().
>
> Now your doubt reduces to the question "Is main() a intterupt handler or a
> task ?".
>
>        Certainly, it is not an interrupt handler as it is the routine that
> enables interrupts for the first time.
>
>        Is it a task ?
>
> Once execution starts, tasks can be posted and main() is the point where
> your system execution starts. Therefore, main() is neither a task nor an
> interrupt handler. However, I do not want group it under a separate 3rd
> category as execution has to start somewhere and it starts at main().
>
> Anybody: If I am wrong please correct me.
>
> Regards,
> Manjunath D
>
>
> ################################################################################################################
>
> ***************************************************************************************************************
>
>
> On Wed, 6 Jan 2010, zheng manchun wrote:
>
>  Hi, I'm reading the Execution Model Chapter of TinyOS programming book
>> recently.
>> I've got some difficulties in understanding the execution model of the
>> example application Blink.
>>
>> As stated in the book, code is either synchronous or asynchronous.
>> And execution might be either a task or an interrupt handler.
>>
>> When the hardware boots successfully, Boot.booted event is signaled.
>> While event booted is defined as synchronous in the Interface Boot, then
>> Boot.booted can not be invoked by an interrupt handler.
>> Therefore, it can only be a task. Or there is a 3rd kind of execution
>> (besides task and interrupt handler)?
>>
>> I hope that some one can help to explain the execution model of the
>> application Blink for me.
>>
>> Thanks in advance.
>>
>> ===================================================
>> //BlinkAppC.nc
>> configuration BlinkAppC
>> {
>> }
>> implementation
>> {
>>  components MainC, BlinkC, LedsC;
>>  components new TimerMilliC() as Timer0;
>>  components new TimerMilliC() as Timer1;
>>  components new TimerMilliC() as Timer2;
>>
>>
>>  BlinkC -> MainC.Boot;
>>
>>  BlinkC.Timer0 -> Timer0;
>>  BlinkC.Timer1 -> Timer1;
>>  BlinkC.Timer2 -> Timer2;
>>  BlinkC.Leds -> LedsC;
>> }
>>
>> ////////////////////////////////////////////////////////////////////////////////////////////////////
>> //BlinkC.nc
>> #include "Timer.h"
>>
>> module BlinkC @safe()
>> {
>>  uses interface Timer<TMilli> as Timer0;
>>  uses interface Timer<TMilli> as Timer1;
>>  uses interface Timer<TMilli> as Timer2;
>>  uses interface Leds;
>>  uses interface Boot;
>> }
>> implementation
>> {
>>  event void Boot.booted()
>>  {
>>   call Timer0.startPeriodic( 250 );
>>   call Timer1.startPeriodic( 500 );
>>   call Timer2.startPeriodic( 1000 );
>>  }
>>
>>  event void Timer0.fired()
>>  {
>>   dbg("BlinkC", "Timer 0 fired @ %s.\n", sim_time_string());
>>   call Leds.led0Toggle();
>>  }
>>
>>  event void Timer1.fired()
>>  {
>>   dbg("BlinkC", "Timer 1 fired @ %s \n", sim_time_string());
>>   call Leds.led1Toggle();
>>  }
>>
>>  event void Timer2.fired()
>>  {
>>   dbg("BlinkC", "Timer 2 fired @ %s.\n", sim_time_string());
>>   call Leds.led2Toggle();
>>  }
>> }
>> =====================================================
>> --
>> Thanks & Best Regards,
>> Mc
>>
>>


-- 
Thanks & Best Regards,
Manchun
_______________________________________________
Tinyos-help mailing list
[email protected]
https://www.millennium.berkeley.edu/cgi-bin/mailman/listinfo/tinyos-help

Reply via email to