FreeRTOS Support Archive
The FreeRTOS support forum is used to obtain active support directly from Real
Time Engineers Ltd. In return for using our top quality software and services for
free, we request you play fair and do your bit to help others too! Sign up
to receive notifications of new support topics then help where you can.
This is a read only archive of threads posted to the FreeRTOS support forum.
The archive is updated every week, so will not always contain the very latest posts.
Use these archive pages to search previous posts. Use the Live FreeRTOS Forum
link to reply to a post, or start a new support thread.
[FreeRTOS Home] [Live FreeRTOS Forum] [FAQ] [Archive Top] [April 2009 Threads] calling vTaskDelete when in critical sectionPosted by mizer on April 2, 2009 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.
RE: calling vTaskDelete when in critical sectPosted by Richard on April 3, 2009 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.
Copyright (C) Amazon Web Services, Inc. or its affiliates. All rights reserved.
|