Skip to content

Commit f50d476

Browse files
change(freertos/smp): Updated event_groups.c to have original critical 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().
1 parent ec1551e commit f50d476

File tree

1 file changed

+24
-8
lines changed

1 file changed

+24
-8
lines changed

event_groups.c

+24-8
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,22 @@
7272

7373
/*-----------------------------------------------------------*/
7474

75+
/*
76+
* When the port is using granular locks, the critical sections are replaced
77+
* with the granular lock API.
78+
*/
79+
#if ( ( portUSING_GRANULAR_LOCKS == 1 ) && ( configNUMBER_OF_CORES > 1 ) )
80+
#undef taskENTER_CRITICAL
81+
#undef taskEXIT_CRITICAL
82+
#undef taskENTER_CRITICAL_FROM_ISR
83+
#undef taskEXIT_CRITICAL_FROM_ISR
84+
85+
#define taskENTER_CRITICAL() taskLOCK_DATA_GROUP( &( pxEventBits->xTaskSpinlock ), &( pxEventBits->xISRSpinlock ) )
86+
#define taskEXIT_CRITICAL() taskUNLOCK_DATA_GROUP( &( pxEventBits->xTaskSpinlock ), &( pxEventBits->xISRSpinlock ) )
87+
#define taskENTER_CRITICAL_FROM_ISR() taskLOCK_DATA_GROUP_FROM_ISR( &( pxEventBits->xISRSpinlock ) )
88+
#define taskEXIT_CRITICAL_FROM_ISR( x ) taskUNLOCK_DATA_GROUP_FROM_ISR( x, &( pxEventBits->xISRSpinlock ) )
89+
#endif /* #if ( ( portUSING_GRANULAR_LOCKS == 1 ) && ( configNUMBER_OF_CORES > 1 ) ) */
90+
7591
/*
7692
* Suspends an event group. Prevents other tasks from accessing the queue but allows
7793
* ISRs to pend access to the queue. Caller cannot be preempted by other tasks
@@ -327,7 +343,7 @@
327343
if( ( uxReturn & eventUNBLOCKED_DUE_TO_BIT_SET ) == ( EventBits_t ) 0 )
328344
{
329345
/* The task timed out, just return the current event bit value. */
330-
taskLOCK_DATA_GROUP( &( pxEventBits->xTaskSpinlock ), &( pxEventBits->xISRSpinlock ) );
346+
taskENTER_CRITICAL();
331347
{
332348
uxReturn = pxEventBits->uxEventBits;
333349

@@ -344,7 +360,7 @@
344360
mtCOVERAGE_TEST_MARKER();
345361
}
346362
}
347-
taskUNLOCK_DATA_GROUP( &( pxEventBits->xTaskSpinlock ), &( pxEventBits->xISRSpinlock ) );
363+
taskEXIT_CRITICAL();
348364

349365
xTimeoutOccurred = pdTRUE;
350366
}
@@ -482,7 +498,7 @@
482498

483499
if( ( uxReturn & eventUNBLOCKED_DUE_TO_BIT_SET ) == ( EventBits_t ) 0 )
484500
{
485-
taskLOCK_DATA_GROUP( &( pxEventBits->xTaskSpinlock ), &( pxEventBits->xISRSpinlock ) );
501+
taskENTER_CRITICAL();
486502
{
487503
/* The task timed out, just return the current event bit value. */
488504
uxReturn = pxEventBits->uxEventBits;
@@ -507,7 +523,7 @@
507523

508524
xTimeoutOccurred = pdTRUE;
509525
}
510-
taskUNLOCK_DATA_GROUP( &( pxEventBits->xTaskSpinlock ), &( pxEventBits->xISRSpinlock ) );
526+
taskEXIT_CRITICAL();
511527
}
512528
else
513529
{
@@ -542,7 +558,7 @@
542558
configASSERT( xEventGroup );
543559
configASSERT( ( uxBitsToClear & eventEVENT_BITS_CONTROL_BYTES ) == 0 );
544560

545-
taskLOCK_DATA_GROUP( &( pxEventBits->xTaskSpinlock ), &( pxEventBits->xISRSpinlock ) );
561+
taskENTER_CRITICAL();
546562
{
547563
traceEVENT_GROUP_CLEAR_BITS( xEventGroup, uxBitsToClear );
548564

@@ -553,7 +569,7 @@
553569
/* Clear the bits. */
554570
pxEventBits->uxEventBits &= ~uxBitsToClear;
555571
}
556-
taskUNLOCK_DATA_GROUP( &( pxEventBits->xTaskSpinlock ), &( pxEventBits->xISRSpinlock ) );
572+
taskEXIT_CRITICAL();
557573

558574
traceRETURN_xEventGroupClearBits( uxReturn );
559575

@@ -592,11 +608,11 @@
592608
/* MISRA Ref 4.7.1 [Return value shall be checked] */
593609
/* More details at: https://github.com/FreeRTOS/FreeRTOS-Kernel/blob/main/MISRA.md#dir-47 */
594610
/* coverity[misra_c_2012_directive_4_7_violation] */
595-
uxSavedInterruptStatus = taskLOCK_DATA_GROUP_FROM_ISR( &( pxEventBits->xISRSpinlock ) );
611+
uxSavedInterruptStatus = taskENTER_CRITICAL_FROM_ISR();
596612
{
597613
uxReturn = pxEventBits->uxEventBits;
598614
}
599-
taskUNLOCK_DATA_GROUP_FROM_ISR( uxSavedInterruptStatus, &( pxEventBits->xISRSpinlock ) );
615+
taskEXIT_CRITICAL_FROM_ISR( uxSavedInterruptStatus );
600616

601617
traceRETURN_xEventGroupGetBitsFromISR( uxReturn );
602618

0 commit comments

Comments
 (0)