@@ -5482,7 +5482,12 @@ BaseType_t xTaskRemoveFromEventList( const List_t * const pxEventList )
5482
5482
5483
5483
traceENTER_xTaskRemoveFromEventList ( pxEventList );
5484
5484
5485
- #if ( ( portUSING_GRANULAR_LOCKS == 1 ) && ( configNUMBER_OF_CORES > 1 ) )
5485
+ #if ( ! ( ( portUSING_GRANULAR_LOCKS == 1 ) && ( configNUMBER_OF_CORES > 1 ) ) )
5486
+
5487
+ /* THIS FUNCTION MUST BE CALLED FROM A CRITICAL SECTION. It can also be
5488
+ * called from a critical section within an ISR. */
5489
+
5490
+ #else /* #if ( ! ( ( portUSING_GRANULAR_LOCKS == 1 ) && ( configNUMBER_OF_CORES > 1 ) ) ) */
5486
5491
/* Lock the kernel data group as we are about to access its members */
5487
5492
UBaseType_t uxSavedInterruptStatus ;
5488
5493
@@ -5495,11 +5500,13 @@ BaseType_t xTaskRemoveFromEventList( const List_t * const pxEventList )
5495
5500
uxSavedInterruptStatus = 0 ;
5496
5501
taskLOCK_DATA_GROUP ( & xTaskSpinlock , & xISRSpinlock );
5497
5502
}
5498
- #else /* #if ( ( portUSING_GRANULAR_LOCKS == 1 ) && ( configNUMBER_OF_CORES > 1 ) ) */
5499
5503
5500
- /* THIS FUNCTION MUST BE CALLED FROM A CRITICAL SECTION. It can also be
5501
- * called from a critical section within an ISR. */
5502
- #endif /* #if ( ( portUSING_GRANULAR_LOCKS == 1 ) && ( configNUMBER_OF_CORES > 1 ) ) */
5504
+ /* Before taking the kernel lock, another task/ISR could have already
5505
+ * emptied the pxEventList. So we insert a check here to see if
5506
+ * pxEventList is empty before attempting to remove an item from it. */
5507
+ if ( listLIST_IS_EMPTY ( pxEventList ) == pdFALSE )
5508
+ {
5509
+ #endif /* #if ( ! ( ( portUSING_GRANULAR_LOCKS == 1 ) && ( configNUMBER_OF_CORES > 1 ) ) ) */
5503
5510
5504
5511
/* The event list is sorted in priority order, so the first in the list can
5505
5512
* be removed as it is known to be the highest priority. Remove the TCB from
@@ -5580,6 +5587,14 @@ BaseType_t xTaskRemoveFromEventList( const List_t * const pxEventList )
5580
5587
#endif /* #if ( configNUMBER_OF_CORES == 1 ) */
5581
5588
5582
5589
#if ( ( portUSING_GRANULAR_LOCKS == 1 ) && ( configNUMBER_OF_CORES > 1 ) )
5590
+ }
5591
+ else
5592
+ {
5593
+ /* The pxEventList was emptied before we entered the critical
5594
+ * section, Nothing to do except return pdFALSE. */
5595
+ xReturn = pdFALSE ;
5596
+ }
5597
+
5583
5598
/* We are done accessing the kernel data group. Unlock it. */
5584
5599
if ( portCHECK_IF_IN_ISR () == pdTRUE )
5585
5600
{
0 commit comments