Page 1 of 1

OSCreate and OS_Replace

PostPosted: Tue Nov 05, 2002 9:03 am
by luben
Hello,

I made a mistake in my last project, creating 2 different tasks with the same TCB. The OSSched was not running - just I created 2 tasks one after other with the same TCB. The result was that the first task j was not running at all. The second task was working without visible problems. And of course there was no error message - neigther in the compiling nor in the linking.

My question is - if I do the same mistake after OSShed was alrady called, what could happen.... I know that OS_Replace is already made and tested, but why you just don't call OSCreate again from the main level, if you want to replace one task with other. Or to say it with other words - is it possible to use OSCreate(TASK_n,..) from other then the Task_n task instead of OS_Replace?


Regards
Luben


Re: OSCreate and OS_Replace

PostPosted: Tue Nov 05, 2002 9:31 am
by aek
Hi Luben.
quote:
And of course there was no error message - neigther in the compiling nor in the linking.
Nor during runtime -- we made the choice to allow users to "overwrite" tasks with new tasks because ultimately it saves ROM. But you do have to be careful ...
quote:
is it possible to use OSCreate(TASK_n,..) from other then the Task_n task instead of OS_Replace?
Yes, you can, but with caution. It really only works if the task is stopped or eligible. If the task is delayed or waiting on an event, things will break because OSCreateTask() does not remove a task from the queue(s) it's in. That's why you should use OS_Replace() (which only works on the current, running task -- obviously) because it avoids these problems.

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