Skip to content

Commit

Permalink
change(freertos/smp): Updated event_groups.c to have original critica…
Browse files Browse the repository at this point in the history
…l sections

This commit reverts the critical sections to use the original version,
a.k.a, taskENTER/EXIT_CRITICAL(). When granular locks are enabled, these
macros get redefined to taskLOCK/UNLOCK_DATA_GROUP().
  • Loading branch information
sudeep-mohanty committed Oct 31, 2024
1 parent 353d6b3 commit c79962d
Showing 1 changed file with 24 additions and 8 deletions.
32 changes: 24 additions & 8 deletions event_groups.c
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,22 @@

/*-----------------------------------------------------------*/

/*
* When the port is using granular locks, the critical sections are replaced
* with the granular lock API.
*/
#if ( ( portUSING_GRANULAR_LOCKS == 1 ) && ( configNUMBER_OF_CORES > 1 ) )
#undef taskENTER_CRITICAL
#undef taskEXIT_CRITICAL
#undef taskENTER_CRITICAL_FROM_ISR
#undef taskEXIT_CRITICAL_FROM_ISR

#define taskENTER_CRITICAL() taskLOCK_DATA_GROUP( &( pxEventBits->xTaskSpinlock ), &( pxEventBits->xISRSpinlock ) )
#define taskEXIT_CRITICAL() taskUNLOCK_DATA_GROUP( &( pxEventBits->xTaskSpinlock ), &( pxEventBits->xISRSpinlock ) )
#define taskENTER_CRITICAL_FROM_ISR() taskLOCK_DATA_GROUP_FROM_ISR( &( pxEventBits->xISRSpinlock ) )
#define taskEXIT_CRITICAL_FROM_ISR( x ) taskUNLOCK_DATA_GROUP_FROM_ISR( x, &( pxEventBits->xISRSpinlock ) )
#endif /* #if ( ( portUSING_GRANULAR_LOCKS == 1 ) && ( configNUMBER_OF_CORES > 1 ) ) */

/*
* Suspends an event group. Prevents other tasks from accessing the queue but allows
* ISRs to pend access to the queue. Caller cannot be preempted by other tasks
Expand Down Expand Up @@ -327,7 +343,7 @@
if( ( uxReturn & eventUNBLOCKED_DUE_TO_BIT_SET ) == ( EventBits_t ) 0 )
{
/* The task timed out, just return the current event bit value. */
taskLOCK_DATA_GROUP( &( pxEventBits->xTaskSpinlock ), &( pxEventBits->xISRSpinlock ) );
taskENTER_CRITICAL();
{
uxReturn = pxEventBits->uxEventBits;

Expand All @@ -344,7 +360,7 @@
mtCOVERAGE_TEST_MARKER();
}
}
taskUNLOCK_DATA_GROUP( &( pxEventBits->xTaskSpinlock ), &( pxEventBits->xISRSpinlock ) );
taskEXIT_CRITICAL();

xTimeoutOccurred = pdTRUE;
}
Expand Down Expand Up @@ -482,7 +498,7 @@

if( ( uxReturn & eventUNBLOCKED_DUE_TO_BIT_SET ) == ( EventBits_t ) 0 )
{
taskLOCK_DATA_GROUP( &( pxEventBits->xTaskSpinlock ), &( pxEventBits->xISRSpinlock ) );
taskENTER_CRITICAL();
{
/* The task timed out, just return the current event bit value. */
uxReturn = pxEventBits->uxEventBits;
Expand All @@ -507,7 +523,7 @@

xTimeoutOccurred = pdTRUE;
}
taskUNLOCK_DATA_GROUP( &( pxEventBits->xTaskSpinlock ), &( pxEventBits->xISRSpinlock ) );
taskEXIT_CRITICAL();
}
else
{
Expand Down Expand Up @@ -542,7 +558,7 @@
configASSERT( xEventGroup );
configASSERT( ( uxBitsToClear & eventEVENT_BITS_CONTROL_BYTES ) == 0 );

taskLOCK_DATA_GROUP( &( pxEventBits->xTaskSpinlock ), &( pxEventBits->xISRSpinlock ) );
taskENTER_CRITICAL();
{
traceEVENT_GROUP_CLEAR_BITS( xEventGroup, uxBitsToClear );

Expand All @@ -553,7 +569,7 @@
/* Clear the bits. */
pxEventBits->uxEventBits &= ~uxBitsToClear;
}
taskUNLOCK_DATA_GROUP( &( pxEventBits->xTaskSpinlock ), &( pxEventBits->xISRSpinlock ) );
taskEXIT_CRITICAL();

traceRETURN_xEventGroupClearBits( uxReturn );

Expand Down Expand Up @@ -592,11 +608,11 @@
/* MISRA Ref 4.7.1 [Return value shall be checked] */
/* More details at: https://github.com/FreeRTOS/FreeRTOS-Kernel/blob/main/MISRA.md#dir-47 */
/* coverity[misra_c_2012_directive_4_7_violation] */
uxSavedInterruptStatus = taskLOCK_DATA_GROUP_FROM_ISR( &( pxEventBits->xISRSpinlock ) );
uxSavedInterruptStatus = taskENTER_CRITICAL_FROM_ISR();
{
uxReturn = pxEventBits->uxEventBits;
}
taskUNLOCK_DATA_GROUP_FROM_ISR( uxSavedInterruptStatus, &( pxEventBits->xISRSpinlock ) );
taskEXIT_CRITICAL_FROM_ISR( uxSavedInterruptStatus );

traceRETURN_xEventGroupGetBitsFromISR( uxReturn );

Expand Down

0 comments on commit c79962d

Please sign in to comment.