Skip to content

Commit 0c79e74

Browse files
authored
Remove run state assertion in prvCheckForRunStateChange (FreeRTOS#1093)
In `prvCheckForRunStateChange()`, enabling interrupts should cause this core to immediately service the pending interrupt and yield. Upon the next scheduling of the task, the assertion `configASSERT(pxThisTCB->xTaskRunState != taskTASK_SCHEDULED_TO_YIELD);` may not be true, as other cores could have requested a yield for this task before it evaluates its run state within the assertion. To address this, the task re-evaluates its run state in critical section within a loop until it is eligible for execution, which is the current implementation. Consequently, this assertion should be removed to ensure correct behavior.
1 parent 76eb443 commit 0c79e74

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

tasks.c

+5-4
Original file line numberDiff line numberDiff line change
@@ -845,10 +845,11 @@ static void prvAddNewTaskToReadyList( TCB_t * pxNewTCB ) PRIVILEGED_FUNCTION;
845845

846846
portENABLE_INTERRUPTS();
847847

848-
/* Enabling interrupts should cause this core to immediately
849-
* service the pending interrupt and yield. If the run state is still
850-
* yielding here then that is a problem. */
851-
configASSERT( pxThisTCB->xTaskRunState != taskTASK_SCHEDULED_TO_YIELD );
848+
/* Enabling interrupts should cause this core to immediately service
849+
* the pending interrupt and yield. After servicing the pending interrupt,
850+
* the task needs to re-evaluate its run state within this loop, as
851+
* other cores may have requested this task to yield, potentially altering
852+
* its run state. */
852853

853854
portDISABLE_INTERRUPTS();
854855
portGET_TASK_LOCK();

0 commit comments

Comments
 (0)