# setting own prioirity using task handle

**URL:** <https://forums.freertos.org/t/setting-own-prioirity-using-task-handle/4406>\
**Category:** Kernel\
**Created:** [June 2, 2007, 10:50pm UTC](https://forums.freertos.org/t/setting-own-prioirity-using-task-handle/4406 "2007-06-02T22:50:37Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![system](https://d2v6vdsk2p900z.cloudfront.net/original/1X/7fc8fdb729c645aab5b20282bbe34e57cb407be6.jpeg) [@system](https://forums.freertos.org/u/system)\
**Post date:** [June 2, 2007, 10:50pm UTC](https://forums.freertos.org/t/setting-own-prioirity-using-task-handle/4406/1 "2007-06-02T22:50:37Z")

</div>

**anonymous** wrote on [Saturday, June 02, 2007](https://sourceforge.net/p/freertos/discussion/382005/thread/bd21c56d/#f436):

Richard

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;  
}

Glen

---

<div class="post-metadata">

**Author:** ![system](https://d2v6vdsk2p900z.cloudfront.net/original/1X/7fc8fdb729c645aab5b20282bbe34e57cb407be6.jpeg) [@system](https://forums.freertos.org/u/system)\
**Post date:** [June 20, 2007, 2:36pm UTC](https://forums.freertos.org/t/setting-own-prioirity-using-task-handle/4406/2 "2007-06-20T14:36:46Z")

</div>

**anonymous** wrote on [Wednesday, June 20, 2007](https://sourceforge.net/p/freertos/discussion/382005/thread/bd21c56d/#f436/ce7b):

Richard

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.

---

<div class="post-metadata">

**Author:** ![rtel](https://d3iykfbgfh8zhg.cloudfront.net/user_avatar/forums.freertos.org/rtel/32/31_2.png) [@rtel](https://forums.freertos.org/u/rtel)\
**Post date:** [June 20, 2007, 2:48pm UTC](https://forums.freertos.org/t/setting-own-prioirity-using-task-handle/4406/3 "2007-06-20T14:48:14Z")

</div>

**[rtel](https://sourceforge.net/u/rtel/)** wrote on [Wednesday, June 20, 2007](https://sourceforge.net/p/freertos/discussion/382005/thread/bd21c56d/#f436/ce7b/83a5):

Hi Glen, I didn’t realise you were waiting for a reply.&nbsp; Thanks for drawing my attention to this.&nbsp; 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 [FreeRTOS.org](http://FreeRTOS.org) code too.&nbsp; I cannot think of why the change shouldn’t be implemented.

Regards.

---

<div class="post-metadata">

**Author:** ![system](https://d2v6vdsk2p900z.cloudfront.net/original/1X/7fc8fdb729c645aab5b20282bbe34e57cb407be6.jpeg) [@system](https://forums.freertos.org/u/system)\
**Post date:** [June 21, 2007, 4:02am UTC](https://forums.freertos.org/t/setting-own-prioirity-using-task-handle/4406/4 "2007-06-21T04:02:22Z")

</div>

**anonymous** wrote on [Thursday, June 21, 2007](https://sourceforge.net/p/freertos/discussion/382005/thread/bd21c56d/#f436/1e7e):

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.

Cheers  
Glen
