I am using the RL-RTX Kernel
What I am trying to do is delete a task before it is created.
As I understand the docs for os_tsk_delete it should return OS_R_NOK if the task cannot be deleted.
For some reason the Kernel gets stuck in the idle task.
Here is some code:
if (os_tsk_delete (id_BiasSupply) == OS_R_OK) { /* task deleted */ id_BiasSupply = os_tsk_create (BiasSupply, 1); SetBiasSupplyTenthVolts (0, 10); } else { /* Task not deleted */ id_BiasSupply = os_tsk_create (BiasSupply, 1); SetBiasSupplyTenthVolts (0, 10); }
In the Keil simulator the statement: id_BiasSupply = os_tsk_create (BiasSupply, 1); never gets executed the kernel just stays in the idle task. Any ideas?
The reason that I want to do this is that I want to make sure that more than one instance of the task is not running at the same time. So I want to just delete the task and if the delete fails then I can go ahead and create the task.
which device are you using?
I am using the AT91M55800A.
If you have not created a task, there is no valid task_id to delete. If you have a zero in the task_id that you are trying to delete, that is considered a tsk_delete_self call, deleting the currently running task. I would bet the only 2 tasks left are the idle task and the timer task. So it appears as though it is doing what you have asked it to do.
os_create_tsk returns a task_id. This ID is only of any use during the time in which that task actaully exists. Once it is not running, it is no longer of use (and may have been assigned to another task, in which case it could cause other system side effetcs).
You COULD (though I am not suggesting that this will make ALL your code correct) change it to
if (id_BiasSupply) // assuming id_BiasSupply is 0 to start { os_tsk_delete (id_Biassupply); id_BiasSupply = 0; } id_BiasSupply = os_tsk_create(BiasSupply, 1); SetBiasSupplyTenthVolts (0, 10);
Thanks for the information. The way that the documentation is written implies that a value gets returned if the task id does not exist. So you could do the sort of thing that I was trying to do.
I also found that you cannot delete a timer which does not exist.