Good point. Nevertheless, in my experience, I would say that when dealing with one node receiving from many others, async command/function can happen relatively easy, and some variables could be overwritten. So to protect them could be worthy.
I am not an expert, can the same event be called twice? Or rather, it has to wait till the first call is finished? Another question: imagine that an event is executing and gets to call a C like function. So immediately, the scheduler starts running the C function. If the same event is called again before the C function has finished, what could it happen? I think that the event variables of the first call could be overwritten with this second call. Does it make sens? Cheers! Sergio On Thu, Apr 14, 2011 at 3:18 PM, 徐瑞涛 <[email protected]> wrote: > Hi, > > Acoording to *TinyOS Programming Manual*, by default one function (it could > be event or command) is sync and it could only be preempted by an async > function (for example: an interrupt handler). But, obviously, uartIn and > uartQueue is private and can't be accessed in any async function. So, I > think it's useless to put atomic here. > > Best Regards, > Ruitao Xu > > > 在 2011年4月14日 上午1:26,Sergio Valcarcel <[email protected]>写道: >> >> Hi, >> >> I imagine that either "uartQueue" or "uartIn" could be accessed from >> another method. If it is not the case I do not see the usefulness >> either. >> >> Have a great (perhaps sunny-spring) day!! >> Sergio >> >> On Wed, Apr 13, 2011 at 9:55 AM, 徐瑞涛 <[email protected]> wrote: >> > Hi, >> > >> > I'm also confused. Looking forward to detailed explanation. >> > >> > Best Regards, >> > Ruitao Xu >> > >> > 在 2011年4月11日 上午10:07,许长亮 <[email protected]>写道: >> >> >> >> Hi: >> >> >> >> I am confued by the following keyword "atomic": >> >> >> >> >> >> message_t* receive(message_t *msg, void *payload, uint8_t len) { >> >> message_t *ret = msg; >> >> >> >> atomic { >> >> if (!uartFull) >> >> { >> >> ret = uartQueue[uartIn]; >> >> uartQueue[uartIn] = msg; >> >> ... >> >> } >> >> ... >> >> } >> >> >> >> I think the context of these codes excute is "task specific ", no >> >> interrupt occurs. so there is no need to use the keyword "atomic". any >> >> on >> >> give me a shorter explanation? thanks! >> >> >> >> >> >> Best regards! >> >> >> >> [email protected] >> >> _______________________________________________ >> >> Tinyos-help mailing list >> >> [email protected] >> >> >> >> https://www.millennium.berkeley.edu/cgi-bin/mailman/listinfo/tinyos-help >> > >> > >> > >> > -- >> > Be Your Personal Best! >> > >> > _______________________________________________ >> > Tinyos-help mailing list >> > [email protected] >> > https://www.millennium.berkeley.edu/cgi-bin/mailman/listinfo/tinyos-help >> > > > > > -- > Be Your Personal Best! > _______________________________________________ Tinyos-help mailing list [email protected] https://www.millennium.berkeley.edu/cgi-bin/mailman/listinfo/tinyos-help
