From 6907d1d62243c9541ff0cbb5ac1ca7d66ebab6ff Mon Sep 17 00:00:00 2001 From: Gaurav Aggarwal Date: Tue, 6 Feb 2024 11:59:06 +0000 Subject: [PATCH] Update comments Signed-off-by: Gaurav Aggarwal --- tasks.c | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/tasks.c b/tasks.c index ba9e9c328..5cda6ec85 100644 --- a/tasks.c +++ b/tasks.c @@ -2268,11 +2268,13 @@ static void prvInitialiseNewTask( TaskFunction_t pxTaskCode, portPRE_TASK_DELETE_HOOK( pxTCB, &( xYieldPendings[ pxTCB->xTaskRunState ] ) ); #endif - /* It is important that to request the deleted task to yield before leaving - * the critical section. The deleted task may be blocked at the entry - * of critical section or scheduler suspension. Without requesting this - * task to yield, this task may void the task deletion by putting itself - * back to another list. */ + /* In the case of SMP, it is possible that the task being deleted + * is running on another core. We must evict the task before + * exiting the critical section to ensure that the task cannot + * take an action which puts it back on ready/state/event list, + * thereby nullifying the delete operation. Once evicted, the + * task won't be scheduled ever as it will no longer be on the + * ready list. */ #if ( configNUMBER_OF_CORES > 1 ) { if( taskTASK_IS_RUNNING( pxTCB ) == pdTRUE ) @@ -3162,11 +3164,13 @@ static void prvInitialiseNewTask( TaskFunction_t pxTaskCode, } #endif /* if ( configUSE_TASK_NOTIFICATIONS == 1 ) */ - /* It is important that to request the suspended task yield before leaving - * the critical section. The suspended task may be blocked at the entry - * of critical section or scheduler suspension. Without requesting this - * task to yield, this task may void the task suspension by putting itself - * back to another list. */ + /* In the case of SMP, it is possible that the task being suspended + * is running on another core. We must evict the task before + * exiting the critical section to ensure that the task cannot + * take an action which puts it back on ready/state/event list, + * thereby nullifying the suspend operation. Once evicted, the + * task won't be scheduled before it is resumed as it will no longer + * be on the ready list. */ #if ( configNUMBER_OF_CORES > 1 ) { if( xSchedulerRunning != pdFALSE )