View unanswered posts | View active topics It is currently Sat Sep 20, 2014 2:56 am






Reply to topic  [ 3 posts ] 
RobotC task alive function 
Author Message
Rookie

Joined: Mon Oct 01, 2007 11:56 am
Posts: 7
Location: England
Post RobotC task alive function
Hi,

Is there a function in RobotC that allows you to see if a task is running? If not, would there be a simple way of working it out that didn't require the thread to be on a quick loop.

Thanks


Fri Nov 30, 2007 12:34 pm
Profile WWW
Expert
User avatar

Joined: Fri Nov 09, 2007 4:51 am
Posts: 121
Location: Hungary, Europe
Post Re: RobotC task alive function
quirkey wrote:
Is there a function in RobotC that allows you to see if a task is running?


I did not yet meet the problem (new in RobotC) and found no explicit task status variable, but it can be solved "manually."

Define a global bool variable for each task you have to keep track and initialize them to false. The variable shall be set to true in very first statement of the task it belongs thus it will be executed when the task is initiated by StartTask(). The variable shall be reset to false at every occasion where StopAllTasks() or StopTask() are invoked.

Now these bool variables will follow the dead or alive status of the tasks.


Fri Dec 07, 2007 2:50 pm
Profile
Rookie

Joined: Sun Jul 22, 2007 6:32 pm
Posts: 16
Location: Ireland
Post Watchdog timer
Another approach is a "watchdog timer" - each task is assigned a global counter variable which it increments periodically (e.g. each time through a loop, or after a specified time interval).

You define a watchdog task who's sole purpose is to ensure that each task's counter is periodically updated. The watchdog can wake up every 10 seconds and will decrement each task's counter. If a task's counter reaches zero then the watchdog task assumes that the task has died and restarts it. It's up to each task to periodically update its watchdog counter.

As the NXT firmware can only support 10 concurrent tasks, and the watchdog task must be one of those tasks, you have a switch statement with nine conditions on which task to restart.

Regards,
Mark


Fri Jan 04, 2008 6:09 pm
Profile WWW
Display posts from previous:  Sort by  
Reply to topic   [ 3 posts ] 

Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  



Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Designed by ST Software for PTF.