On Jul 29, 2006, at 11:02 PM, Hui KANG wrote:


Dr. Levis:
After reading Section 4.4 about Tasks in your book, "TinyOS
programming",
I still have some problem.


Please send questions to tinyos-help. That way everyone can benefit from the answers, and they are entered in the online archives for future users.

1: For the code example in pp 31, you said signalling an even from within
a command is
a bad idea, since it can cause call loops. But actually in this example, Read.readDone does not call Read.read again. So I think it will not cause
a call
loop. Am I correct?

Correct.



2: Second, to prove there exists a call loop, you modify Read.readDone as
in pp 32.
Herein, it calls Read.read() in Read.readDone(). I agree that in this
example
call loop occurs.
So the modified code in pp 33 post task void readDoneTask() to avoid the
call loop.
Two problems in this code example:
 (a) In this example, RawRead.readDone (should it be Read.readDone() )
       actually does not call Read.read(). If the answer to 1 is yes,
then it seems
no improvement by using task. Both have the same effect. The the code
example in
pp 33 is not suitable to show the benefit of Task.

Take a look at the code on page 34. The question is not whether the provider of Read calls Read.read in Read.readDone, but whether the *user* does. Please look at listing 4.12, entitled "Signal handler that can lead to an infinite loop."


 (b) If assuming that the code example in 33 posted Read.read() in
RawRead.readDone,
does task avoid the call loop? As said, task can run atomicly to other
tasks. But
it is possible that Read.read() preempt to the task. So the call loop
still exists?


No. Look at the next listing.


3: What is the difference between task and an ordinary function, like
   task void ProcessData() and void ProcessData();
I am a little bit confused. Thanks.

A function executes immediately. A task executes later.

Phil

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

Reply via email to