Skip to content

Commit 76a9b26

Browse files
feat(freertos-smp): Added xTaskHigherPriorityTasksReady for event groups
1 parent 512492e commit 76a9b26

File tree

3 files changed

+47
-0
lines changed

3 files changed

+47
-0
lines changed

event_groups.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -899,6 +899,13 @@
899899
/* Return true as the task was preempted */
900900
xReturn = pdTRUE;
901901
}
902+
else if( xTaskHigherPriorityTasksReady() == pdTRUE )
903+
{
904+
/* Higher priority tasks are ready to run */
905+
taskYIELD_WITHIN_API();
906+
907+
xReturn = pdTRUE;
908+
}
902909
else
903910
{
904911
/* Return false as the task was not preempted */

include/task.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3883,6 +3883,16 @@ void vTaskInternalSetTimeOutState( TimeOut_t * const pxTimeOut ) PRIVILEGED_FUNC
38833883
BaseType_t xTaskUnlockCanYield( void );
38843884
#endif /* #if ( ( portUSING_GRANULAR_LOCKS == 1 ) && ( configNUMBER_OF_CORES > 1 ) ) */
38853885

3886+
/*
3887+
* Returns pdTRUE if there are higher priority tasks ready to run
3888+
* on the current core than the current task. This is intended for
3889+
* use by kernel objects (like event groups) that need to make
3890+
* yield decisions when unlocking.
3891+
*/
3892+
#if ( ( portUSING_GRANULAR_LOCKS == 1 ) && ( configNUMBER_OF_CORES > 1 ) )
3893+
BaseType_t xTaskHigherPriorityTasksReady( void );
3894+
#endif /* #if ( ( portUSING_GRANULAR_LOCKS == 1 ) && ( configNUMBER_OF_CORES > 1 ) ) */
3895+
38863896
#if ( portUSING_MPU_WRAPPERS == 1 )
38873897

38883898
/*

tasks.c

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8048,6 +8048,36 @@ static void prvResetNextTaskUnblockTime( void )
80488048
#endif /* #if ( ( portUSING_GRANULAR_LOCKS == 1 ) && ( configNUMBER_OF_CORES > 1 ) ) */
80498049
/*-----------------------------------------------------------*/
80508050

8051+
#if ( ( portUSING_GRANULAR_LOCKS == 1 ) && ( configNUMBER_OF_CORES > 1 ) )
8052+
8053+
BaseType_t xTaskHigherPriorityTasksReady( void )
8054+
{
8055+
BaseType_t xReturn = pdFALSE;
8056+
BaseType_t xCoreID = portGET_CORE_ID();
8057+
8058+
/* Only check if scheduler is running and not suspended */
8059+
if( ( xSchedulerRunning != pdFALSE ) && ( uxSchedulerSuspended == pdFALSE ) )
8060+
{
8061+
#if ( configUSE_TASK_PREEMPTION_DISABLE == 1 )
8062+
if( pxCurrentTCBs[ xCoreID ]->uxPreemptionDisable == 0U )
8063+
#endif
8064+
{
8065+
UBaseType_t uxCurrentPriority = pxCurrentTCBs[ xCoreID ]->uxPriority;
8066+
8067+
/* Simple check: is top ready priority higher than current? */
8068+
if( uxTopReadyPriority > uxCurrentPriority )
8069+
{
8070+
xReturn = pdTRUE;
8071+
}
8072+
}
8073+
}
8074+
8075+
return xReturn;
8076+
}
8077+
8078+
#endif /* #if ( ( portUSING_GRANULAR_LOCKS == 1 ) && ( configNUMBER_OF_CORES > 1 ) ) */
8079+
/*-----------------------------------------------------------*/
8080+
80518081
#if ( configUSE_STATS_FORMATTING_FUNCTIONS > 0 )
80528082

80538083
static char * prvWriteNameToBuffer( char * pcBuffer,

0 commit comments

Comments
 (0)