From 829d8ba51a636547a86671de2fad5d7d4b000813 Mon Sep 17 00:00:00 2001 From: Sudeep Mohanty Date: Wed, 20 Aug 2025 14:48:25 +0200 Subject: [PATCH] fix(freertos-smp): Remove scheduler suspension from event_groups.c This commit removes the need for suspending the scheduler when calling some event_groups.c APIs as the non-deterministic operations are happening with the event group being locked and the preemption being disabled from the current task. --- event_groups.c | 22 ---------------------- tasks.c | 9 ++++++--- 2 files changed, 6 insertions(+), 25 deletions(-) diff --git a/event_groups.c b/event_groups.c index 9f31e5b8c..88de87b84 100644 --- a/event_groups.c +++ b/event_groups.c @@ -621,13 +621,6 @@ { traceEVENT_GROUP_SET_BITS( xEventGroup, uxBitsToSet ); - #if ( ( portUSING_GRANULAR_LOCKS == 1 ) && ( configNUMBER_OF_CORES > 1 ) ) - - /* We are about to access the kernel data group non-deterministically, - * thus we suspend the kernel data group.*/ - vTaskSuspendAll(); - #endif /* #if ( ( portUSING_GRANULAR_LOCKS == 1 ) && ( configNUMBER_OF_CORES > 1 ) ) */ - pxListItem = listGET_HEAD_ENTRY( pxList ); /* Set the bits. */ @@ -698,10 +691,6 @@ /* Snapshot resulting bits. */ uxReturnBits = pxEventBits->uxEventBits; - - #if ( ( portUSING_GRANULAR_LOCKS == 1 ) && ( configNUMBER_OF_CORES > 1 ) ) - ( void ) xTaskResumeAll(); - #endif /* #if ( ( portUSING_GRANULAR_LOCKS == 1 ) && ( configNUMBER_OF_CORES > 1 ) ) */ } ( void ) event_groupsUNLOCK( pxEventBits ); @@ -726,13 +715,6 @@ { traceEVENT_GROUP_DELETE( xEventGroup ); - #if ( ( portUSING_GRANULAR_LOCKS == 1 ) && ( configNUMBER_OF_CORES > 1 ) ) - - /* We are about to access the kernel data group non-deterministically, - * thus we suspend the kernel data group.*/ - vTaskSuspendAll(); - #endif /* #if ( ( portUSING_GRANULAR_LOCKS == 1 ) && ( configNUMBER_OF_CORES > 1 ) ) */ - while( listCURRENT_LIST_LENGTH( pxTasksWaitingForBits ) > ( UBaseType_t ) 0 ) { /* Unblock the task, returning 0 as the event list is being deleted @@ -740,10 +722,6 @@ configASSERT( pxTasksWaitingForBits->xListEnd.pxNext != ( const ListItem_t * ) &( pxTasksWaitingForBits->xListEnd ) ); vTaskRemoveFromUnorderedEventList( pxTasksWaitingForBits->xListEnd.pxNext, eventUNBLOCKED_DUE_TO_BIT_SET ); } - - #if ( ( portUSING_GRANULAR_LOCKS == 1 ) && ( configNUMBER_OF_CORES > 1 ) ) - ( void ) xTaskResumeAll(); - #endif /* #if ( ( portUSING_GRANULAR_LOCKS == 1 ) && ( configNUMBER_OF_CORES > 1 ) ) */ } ( void ) event_groupsUNLOCK( pxEventBits ); diff --git a/tasks.c b/tasks.c index f9180ace1..0aac59d1a 100644 --- a/tasks.c +++ b/tasks.c @@ -5977,9 +5977,12 @@ void vTaskRemoveFromUnorderedEventList( ListItem_t * pxEventListItem, traceENTER_vTaskRemoveFromUnorderedEventList( pxEventListItem, xItemValue ); - /* THIS FUNCTION MUST BE CALLED WITH THE SCHEDULER SUSPENDED. It is used by - * the event flags implementation. */ - configASSERT( uxSchedulerSuspended != ( UBaseType_t ) 0U ); + #if ( !( portUSING_GRANULAR_LOCKS == 1 ) ) + + /* THIS FUNCTION MUST BE CALLED WITH THE SCHEDULER SUSPENDED. It is used by + * the event flags implementation. */ + configASSERT( uxSchedulerSuspended != ( UBaseType_t ) 0U ); + #endif /* #if ( ! ( portUSING_GRANULAR_LOCKS == 1 ) ) */ /* Store the new item value in the event list. */ listSET_LIST_ITEM_VALUE( pxEventListItem, xItemValue | taskEVENT_LIST_ITEM_VALUE_IN_USE );