setting own prioirity using task handle

anonymous wrote on Saturday, June 02, 2007:


Quite some time ago I think you added the following code to vTaskDelete() at my request. This was to allow a task to properly delete itself by passing its own task handle rather than NULL. I think a similar addition should be added in to vTaskPrioritySet().

/* Ensure a yield is performed if the current task is being
deleted. */
if( pxTaskToDelete == pxCurrentTCB )
__pxTaskToDelete = NULL;


anonymous wrote on Wednesday, June 20, 2007:


I have seen no response to this.

If that means you intend to do it great.

If it means that you do not, then I think you should re-consider. Currently, if a thread lowers its own priority using its own task handle rather than NULL, and the new priority is lower than the priority of the next higher priority ready task, then it will continue running until the next context switch even though it is not the highest priority task. This would have to be considered a bug in the kernel.

rtel wrote on Wednesday, June 20, 2007:

Hi Glen, I didn’t realise you were waiting for a reply.  Thanks for drawing my attention to this.  It is actually something that was highlighted during the SafeRTOS analysis, and to be honest I cannot remember why I did not migrate the change into the code too.  I cannot think of why the change shouldn’t be implemented.


anonymous wrote on Thursday, June 21, 2007:

No problem. I just wanted to be sure I didn’t leave this hanging without being properly understood.

I was curious about whether it had slipped by into SafeRTOS. It is encouraging to hear that the analysis was thorough enough to catch something like this.