calling vTaskDelete when in critical section

Hi, In case it matters I’m using the AVR32 UC3A port. While in one task I’m calling vTaskDelete to delete a different task. It happens my code to make the vTaskDelete call is within a short taskENTER_CRITICAL section. I see at the end of the vTaskDelete function a taskYield request. My code would still have this within a taskCRITICAL section (due to the nested taskCRITICAL calls). Is this okay? As I think about this further … it seems the act of the taskYIELD call (at the end of the vTaskDelete function) could actually cause a context switch and therefore defeat the purpose of my CRITICAL section. But since we are in a CRITICAL section [by my doing] no event (an interrupt) could’ve taken place that would set up an an actual task yield. I think the task yield section at the end of the vTaskDelete function is primarily for when a task deletes itself (because I suspect you never return from the vTaskDelete function in that case). So the first paragraph is my real question. Any comments appreciated. I sure am enjoying freeRTOS. Seriously! Thanks, Bob.

calling vTaskDelete when in critical section

The Yield at the end of vTaskDelete() is to ensure you yield away from the task that has now been deleted, as it (conceptually) no longer exists (assuming you are deleting the running task rather another task). Some ports will yield immediately and some will hold it pending until you exit the critical section – I cannot remember off hand which the AVR32 port does.  If it yields immediately then any code you place between deleting the task and exiting your critical section will never run because the task will have yielded to another task and never run again (again this assumes you are deleting the running task rather than another task). Regards.