Pumpkin, Inc.

Pumpkin User Forums

Re-using a TCB.

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

Re-using a TCB.

Postby dfleck » Tue Jun 11, 2002 4:51 am

Can I re-use a TCB by just using OSCreateTask(), or must I first use OSDestroyTask() to destroy the current task and then use OSCreateTask()?

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

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

Re: Re-using a TCB.

Postby aek » Tue Jun 11, 2002 7:47 am

Hi Donald.

You must first destroy the task before creating one using the same tcb. Without destroying it first, it could be left in a queue somewhere, causing very unpredictable results.

You'll probably want to check the return code from OSDestroyTask() to ensure that OSDestroyTask() was successful before you call OSCreateTask().

Regards,

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

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

Re: Re-using a TCB.

Postby dfleck » Tue Jun 11, 2002 7:56 am

Thanks. I looked at the code and since OSDestroyTask() calls OSInitTcb() and seems to delete the task from the queue, I assume it is unnecessary to call OSStopTask() before OSDestroyTask(). But please confirm this.

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

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

Re: Re-using a TCB.

Postby aek » Tue Jun 11, 2002 8:04 am

Hi Donald.

Note that OSDestroyTask() cannot be called from the foreground / interrupt level.

Therefore there's no need to call OSStopTask(), since either i) you're in the task itself (in which case you should call OS_Destroy()), or ii) you're somewhere else in background / mainline code, in which case the task isn't running, and you call OSDestroyTask().

Regards,

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

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


Return to Coding

Who is online

Users browsing this forum: No registered users and 1 guest

cron