Hi, On Thursday 21 June 2007 05:15:26 am Zhifeng Lai wrote: > I have some confusion on nesC execution model: > > (1) Is it true that all the code is preemptable, except those contained > in atomic blocks?
This isn't true, at least for TinyOS' use of nesC. Pre-emption in TInyOS is accomplished via hardware interrupts. AFAIK, no TinyOS platforms implement nested interrupts, so from a pre-emption standpoint an atomic block and a call graph executing under an ISR (interrupt service routine) are functionally equivalent. So, this means that only code not running in an atomic block and not running under an ISR is preemptible. A better way to say this is that code running in/under a task that is not in an atomic block is pre-emptable. > (2) What is the difference when we call async and sync command from > tasks? Nothing. A command using the 'async' modifier means that the command is safe to be called from async context, but it can still be called from non-async (task) context. A good example of this is seen in tos2's GeneralIO interface. Event signalling uses the same rules, but has practical differences in behavior. For example, most implementations of an interface defining async events will call them exclusively from async context. This means the signal handlers on the 'using' side of the interface wiring must have the async modifier and will be executed in async context as well. An example of this is GpioInterrupt's fired() event. > (3) Can events have more than one event handlers? Sure. Philip Levis' TinyOS Programming guide talks about fan-out. http://csl.stanford.edu/~pal/pubs/tinyos-programming.pdf All the best, Steve _______________________________________________ Tinyos-help mailing list [email protected] https://mail.millennium.berkeley.edu/cgi-bin/mailman/listinfo/tinyos-help
