Pumpkin, Inc.

Pumpkin User Forums

How do you restart a task?

If you can't make Salvo do what you want it to do, post it here.

How do you restart a task?

Postby aek » Mon Jun 10, 2002 1:10 am

Hi Donald.

Since the task you describe has only a single context switch, by default that's where it must stop and resume when OSStopTask() and OSStartTask() operate on it. IOW, a task's entry points are its beginning and each context switch, and its exit points are each context switch.

I suspect your best bet would be to use a global static variable that contains info on how you would like the task to behave when it is restarted. This variable is initialized prior to creating the task, and is read after OS_Delay(), with the task's execution dependent on its value. You could do something like:

code:
OS_Delay(label);
switch ( behavior ) {
case CONTINUE:
break;
case RESTART:
goto top_of_task_A;
case DELAY_AGAIN:
goto just_before_OSDelay;
default:
break;
}

where you might set behavior to RESTART prior to calling OSStartTask();

Alternatively, you could call OSStopTask(), then OSCreateTask(), re-creating the same task in its place. Note that in this case the task's initial code (before the while(1) loop) will be executed.

------------------

-------
aek
aek
 
Posts: 1888
Joined: Sat Aug 26, 2000 11:00 pm

Re: How do you restart a task?

Postby dfleck » Mon Jun 10, 2002 11:52 am

I have a task (function task_A()) that contains an OS_Delay() at the end of the while(1) loop. If I stop this task via OSStopTask() then start it with OSStartTask() it begins running at the OS_Delay(). How can I make it start from the beginning of task_A()?

------------------
Donald A. Fleck

Donald A. Fleck
dfleck
 
Posts: 28
Joined: Sun May 12, 2002 11:00 pm
Location: Breinigsville, PA, USA


Return to Coding

Who is online

Users browsing this forum: No registered users and 1 guest

cron