On Mar 14, 2006, at 8:09 PM, Tran Trong Tri wrote:

Hi,

Thanks for answering...But even if those copies are put into a queue, does that mean they run sequentially one after another without being interrupted in between like:

...
copy1 done;
copy2 done;
...something else outside that functionF runs..;
copy3;
cop4;
....

a fucntion is not guaranteed unpre-empted, isn't it?



Here's basically how it works in 1.x:

main() {
  // init, start, etc.

  while(1) {
    if (!queueEmpty()) {
      runTask(); // pull the next task off the queue and run it
    }
    else {
      sleep();
    }
  }
}

Take a look at RealMain.nc and sched.c. In reality, it's a little more complicated than the pseudocode above because you need to make sure that the testing for an empty queue and going to sleep is an atomic operation. Otherwise, you might decide that the queue is empty, have an interrupt fire that posts a task, and then go to sleep even though the queue is no longer empty.

Since the scheduler runs tasks one-by-one with a single thread of control, they can't preempt each other.

In 2.x there's a little more mechanism in there for extensible schedulers.

Phil
_______________________________________________
Tinyos-help mailing list
Tinyos-help@Millennium.Berkeley.EDU
https://mail.millennium.berkeley.edu/cgi-bin/mailman/listinfo/tinyos-help

Reply via email to