To LUGNET HomepageTo LUGNET News HomepageTo LUGNET Guide Homepage
 Help on Searching
 
Post new message to lugnet.robotics.rcxOpen lugnet.robotics.rcx in your NNTP NewsreaderTo LUGNET News Traffic PageSign In (Members)
 Robotics / RCX / 2741
2740  |  2742
Subject: 
Swan scheduling bug?
Newsgroups: 
lugnet.robotics.rcx
Date: 
Thu, 22 Sep 2005 14:06:42 GMT
Viewed: 
4555 times
  
I'm starting to use the swan firmware and I'm having a problem with the
scheduling.  It seems like a task with a long wait does not yield properly to
other tasks.  Here the NQC code sample:

task taska()
{
  WaitMS(150);
  AddToDatalog(9900);
}

task main()
{
  CreateDatalog(100);

  ClearTimer(0);
  start taska;
  repeat(5) {
    AddToDatalog(FastTimer(0));
    WaitMS(50);
  }
}

This gives the following datalog:
Variable 1: 0
Variable 2: 9900
Variable 1: 15
Variable 1: 20
Variable 1: 25
Variable 1: 30

Notice that task main yielded at the first wait in the loop but taska did not
yield at its wait so the rest of task main did not get a chance to run until
taska finished.

I found one workaround.  If I replace the long wait with short wait inside a
repeat loop then it yields properly.  Like this:

task taska()
{
  repeat(3) {
    WaitMS(50);
  }
  AddToDatalog(9900);
}

With this code I get the following, correct datalog:

Variable 1: 0
Variable 1: 5
Variable 1: 10
Variable 2: 9900
Variable 1: 15
Variable 1: 20


Gus Jansson



1 Message in This Thread:

Entire Thread on One Page:
Nested:  All | Brief | Compact | Dots
Linear:  All | Brief | Compact
    

Custom Search

©2005 LUGNET. All rights reserved. - hosted by steinbruch.info GbR