mirror of
https://github.com/FreeRTOS/FreeRTOS-Kernel.git
synced 2025-06-06 04:19:05 -04:00
feat(granular_locks): Add granular locking functions
- Updated prvCheckForRunStateChange() for granular locks - Updated vTaskSuspendAll() and xTaskResumeAll() - Now holds the xTaskSpinlock during kernel suspension - Increments/decrements xPreemptionDisable. Only yields when 0, thus allowing for nested suspensions across different data groups Co-authored-by: Sudeep Mohanty <sudeep.mohanty@espressif.com>
This commit is contained in:
parent
87094b4dc8
commit
d0a2b81b1f
|
@ -451,7 +451,7 @@
|
|||
#if ( ( portUSING_GRANULAR_LOCKS == 1 ) || ( configNUMBER_OF_CORES == 1 ) )
|
||||
#define portRELEASE_TASK_LOCK( xCoreID )
|
||||
#else
|
||||
#error portRELEASE_TASK_LOCK is required in SMP
|
||||
#error portRELEASE_TASK_LOCK is required in SMP without granular locking feature enabled
|
||||
#endif
|
||||
|
||||
#endif /* portRELEASE_TASK_LOCK */
|
||||
|
@ -461,7 +461,7 @@
|
|||
#if ( ( portUSING_GRANULAR_LOCKS == 1 ) || ( configNUMBER_OF_CORES == 1 ) )
|
||||
#define portGET_TASK_LOCK( xCoreID )
|
||||
#else
|
||||
#error portGET_TASK_LOCK is required in SMP
|
||||
#error portGET_TASK_LOCK is required in SMP without granular locking feature enabled
|
||||
#endif
|
||||
|
||||
#endif /* portGET_TASK_LOCK */
|
||||
|
@ -471,7 +471,7 @@
|
|||
#if ( ( portUSING_GRANULAR_LOCKS == 1 ) || ( configNUMBER_OF_CORES == 1 ) )
|
||||
#define portRELEASE_ISR_LOCK( xCoreID )
|
||||
#else
|
||||
#error portRELEASE_ISR_LOCK is required in SMP
|
||||
#error portRELEASE_ISR_LOCK is required in SMP without granular locking feature enabled
|
||||
#endif
|
||||
|
||||
#endif /* portRELEASE_ISR_LOCK */
|
||||
|
@ -481,7 +481,7 @@
|
|||
#if ( ( portUSING_GRANULAR_LOCKS == 1 ) || ( configNUMBER_OF_CORES == 1 ) )
|
||||
#define portGET_ISR_LOCK( xCoreID )
|
||||
#else
|
||||
#error portGET_ISR_LOCK is required in SMP
|
||||
#error portGET_ISR_LOCK is required in SMP without granular locking feature enabled
|
||||
#endif
|
||||
|
||||
#endif /* portGET_ISR_LOCK */
|
||||
|
@ -489,7 +489,7 @@
|
|||
#ifndef portRELEASE_SPINLOCK
|
||||
|
||||
#if ( ( portUSING_GRANULAR_LOCKS == 1 ) && ( configNUMBER_OF_CORES > 1 ) )
|
||||
#error portRELEASE_SPINLOCK is required for granular locking
|
||||
#error portRELEASE_SPINLOCK is required for SMP with granular locking feature enabled
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
@ -497,7 +497,7 @@
|
|||
#ifndef portGET_SPINLOCK
|
||||
|
||||
#if ( ( portUSING_GRANULAR_LOCKS == 1 ) && ( configNUMBER_OF_CORES > 1 ) )
|
||||
#error portGET_SPINLOCK is required for granular locking
|
||||
#error portGET_SPINLOCK is required for SMP with granular locking feature enabled
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
@ -526,38 +526,6 @@
|
|||
|
||||
#endif
|
||||
|
||||
#ifndef portENTER_CRITICAL_DATA_GROUP
|
||||
|
||||
#if ( ( portUSING_GRANULAR_LOCKS == 1 ) && ( configNUMBER_OF_CORES > 1 ) )
|
||||
#error portENTER_CRITICAL_DATA_GROUP is required for SMP with granular locking feature enabled
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
#ifndef portEXIT_CRITICAL_DATA_GROUP
|
||||
|
||||
#if ( ( portUSING_GRANULAR_LOCKS == 1 ) && ( configNUMBER_OF_CORES > 1 ) )
|
||||
#error portEXIT_CRITICAL_DATA_GROUP is required for SMP with granular locking feature enabled
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
#ifndef portENTER_CRITICAL_DATA_GROUP_FROM_ISR
|
||||
|
||||
#if ( ( portUSING_GRANULAR_LOCKS == 1 ) && ( configNUMBER_OF_CORES > 1 ) )
|
||||
#error portENTER_CRITICAL_DATA_GROUP_FROM_ISR is required for SMP with granular locking feature enabled
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
#ifndef portEXIT_CRITICAL_DATA_GROUP_FROM_ISR
|
||||
|
||||
#if ( ( portUSING_GRANULAR_LOCKS == 1 ) && ( configNUMBER_OF_CORES > 1 ) )
|
||||
#error portEXIT_CRITICAL_DATA_GROUP_FROM_ISR is required for SMP with granular locking feature enabled
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
#ifndef portSPINLOCK_TYPE
|
||||
|
||||
#if ( ( portUSING_GRANULAR_LOCKS == 1 ) && ( configNUMBER_OF_CORES > 1 ) )
|
||||
|
@ -566,82 +534,18 @@
|
|||
|
||||
#endif
|
||||
|
||||
#ifndef portINIT_EVENT_GROUP_TASK_SPINLOCK
|
||||
#ifndef portINIT_SPINLOCK
|
||||
|
||||
#if ( ( portUSING_GRANULAR_LOCKS == 1 ) && ( configNUMBER_OF_CORES > 1 ) )
|
||||
#error portINIT_EVENT_GROUP_TASK_SPINLOCK is required for granular locking
|
||||
#error portINIT_SPINLOCK is required for SMP with granular locking feature enabled
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
#ifndef portINIT_EVENT_GROUP_ISR_SPINLOCK
|
||||
#ifndef portINIT_SPINLOCK_STATIC
|
||||
|
||||
#if ( ( portUSING_GRANULAR_LOCKS == 1 ) && ( configNUMBER_OF_CORES > 1 ) )
|
||||
#error portINIT_EVENT_GROUP_ISR_SPINLOCK is required for granular locking
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
#ifndef portINIT_QUEUE_TASK_SPINLOCK
|
||||
|
||||
#if ( ( portUSING_GRANULAR_LOCKS == 1 ) && ( configNUMBER_OF_CORES > 1 ) )
|
||||
#error portINIT_QUEUE_TASK_SPINLOCK is required for granular locking
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
#ifndef portINIT_QUEUE_ISR_SPINLOCK
|
||||
|
||||
#if ( ( portUSING_GRANULAR_LOCKS == 1 ) && ( configNUMBER_OF_CORES > 1 ) )
|
||||
#error portINIT_QUEUE_ISR_SPINLOCK is required for granular locking
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
#ifndef portINIT_STREAM_BUFFER_TASK_SPINLOCK
|
||||
|
||||
#if ( ( portUSING_GRANULAR_LOCKS == 1 ) && ( configNUMBER_OF_CORES > 1 ) )
|
||||
#error portINIT_STREAM_BUFFER_TASK_SPINLOCK is required for granular locking
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
#ifndef portINIT_STREAM_BUFFER_ISR_SPINLOCK
|
||||
|
||||
#if ( ( portUSING_GRANULAR_LOCKS == 1 ) && ( configNUMBER_OF_CORES > 1 ) )
|
||||
#error portINIT_STREAM_BUFFER_ISR_SPINLOCK is required for granular locking
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
#ifndef portINIT_KERNEL_TASK_SPINLOCK_STATIC
|
||||
|
||||
#if ( ( portUSING_GRANULAR_LOCKS == 1 ) && ( configNUMBER_OF_CORES > 1 ) )
|
||||
#error portINIT_KERNEL_TASK_SPINLOCK_STATIC is required for granular locking
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
#ifndef portINIT_KERNEL_ISR_SPINLOCK_STATIC
|
||||
|
||||
#if ( ( portUSING_GRANULAR_LOCKS == 1 ) && ( configNUMBER_OF_CORES > 1 ) )
|
||||
#error portINIT_KERNEL_ISR_SPINLOCK_STATIC is required for granular locking
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
#ifndef portINIT_TIMERS_TASK_SPINLOCK_STATIC
|
||||
|
||||
#if ( ( portUSING_GRANULAR_LOCKS == 1 ) && ( configNUMBER_OF_CORES > 1 ) )
|
||||
#error portINIT_TIMERS_TASK_SPINLOCK_STATIC is required for granular locking
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
#ifndef portINIT_TIMERS_ISR_SPINLOCK_STATIC
|
||||
|
||||
#if ( ( portUSING_GRANULAR_LOCKS == 1 ) && ( configNUMBER_OF_CORES > 1 ) )
|
||||
#error portINIT_TIMERS_ISR_SPINLOCK_STATIC is required for granular locking
|
||||
#error portINIT_SPINLOCK_STATIC is required for SMP with granular locking feature enabled
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
@ -3062,7 +2966,7 @@
|
|||
#endif /* #if ( ( portUSING_GRANULAR_LOCKS == 1 ) && ( configNUMBER_OF_CORES > 1 ) ) */
|
||||
#define portTICK_TYPE_SET_INTERRUPT_MASK_FROM_ISR() portSET_INTERRUPT_MASK_FROM_ISR()
|
||||
#define portTICK_TYPE_CLEAR_INTERRUPT_MASK_FROM_ISR( x ) portCLEAR_INTERRUPT_MASK_FROM_ISR( ( x ) )
|
||||
#else
|
||||
#else /* if ( portTICK_TYPE_IS_ATOMIC == 0 ) */
|
||||
|
||||
/* The tick type can be read atomically, so critical sections used when the
|
||||
* tick count is returned can be defined away. */
|
||||
|
|
|
@ -233,6 +233,13 @@ typedef enum
|
|||
#else
|
||||
#define taskENTER_CRITICAL_FROM_ISR() portENTER_CRITICAL_FROM_ISR()
|
||||
#endif
|
||||
#if ( ( portUSING_GRANULAR_LOCKS == 1 ) && ( configNUMBER_OF_CORES > 1 ) )
|
||||
#define taskLOCK_DATA_GROUP( pxTaskSpinlock, pxISRSpinlock ) portLOCK_DATA_GROUP( ( portSPINLOCK_TYPE * ) pxTaskSpinlock, ( portSPINLOCK_TYPE * ) pxISRSpinlock )
|
||||
#define taskLOCK_DATA_GROUP_FROM_ISR( pxISRSpinlock ) portLOCK_DATA_GROUP_FROM_ISR( pxISRSpinlock )
|
||||
#else /* #if ( ( portUSING_GRANULAR_LOCKS == 1 ) && ( configNUMBER_OF_CORES > 1 ) ) */
|
||||
#define taskLOCK_DATA_GROUP( pxTaskSpinlock, pxISRSpinlock ) taskENTER_CRITICAL()
|
||||
#define taskLOCK_DATA_GROUP_FROM_ISR( pxISRSpinlock ) taskENTER_CRITICAL_FROM_ISR()
|
||||
#endif /* #if ( ( portUSING_GRANULAR_LOCKS == 1 ) && ( configNUMBER_OF_CORES > 1 ) ) */
|
||||
|
||||
/**
|
||||
* task. h
|
||||
|
@ -252,6 +259,13 @@ typedef enum
|
|||
#else
|
||||
#define taskEXIT_CRITICAL_FROM_ISR( x ) portEXIT_CRITICAL_FROM_ISR( x )
|
||||
#endif
|
||||
#if ( ( portUSING_GRANULAR_LOCKS == 1 ) && ( configNUMBER_OF_CORES > 1 ) )
|
||||
#define taskUNLOCK_DATA_GROUP( pxTaskSpinlock, pxISRSpinlock ) portUNLOCK_DATA_GROUP( ( portSPINLOCK_TYPE * ) pxTaskSpinlock, ( portSPINLOCK_TYPE * ) pxISRSpinlock )
|
||||
#define taskUNLOCK_DATA_GROUP_FROM_ISR( x, pxISRSpinlock ) portUNLOCK_DATA_GROUP_FROM_ISR( x, pxISRSpinlock )
|
||||
#else /* #if ( ( portUSING_GRANULAR_LOCKS == 1 ) && ( configNUMBER_OF_CORES > 1 ) ) */
|
||||
#define taskUNLOCK_DATA_GROUP( pxTaskSpinlock, pxISRSpinlock ) taskEXIT_CRITICAL()
|
||||
#define taskUNLOCK_DATA_GROUP_FROM_ISR( x, pxISRSpinlock ) taskEXIT_CRITICAL_FROM_ISR( x )
|
||||
#endif /* #if ( ( portUSING_GRANULAR_LOCKS == 1 ) && ( configNUMBER_OF_CORES > 1 ) ) */
|
||||
|
||||
/**
|
||||
* task. h
|
||||
|
@ -3719,7 +3733,7 @@ void vTaskInternalSetTimeOutState( TimeOut_t * const pxTimeOut ) PRIVILEGED_FUNC
|
|||
* It should be used in the implementation of portENTER_CRITICAL if port is running a
|
||||
* multiple core FreeRTOS.
|
||||
*/
|
||||
#if ( ( portCRITICAL_NESTING_IN_TCB == 1 ) || ( configNUMBER_OF_CORES > 1 ) )
|
||||
#if !( ( portUSING_GRANULAR_LOCKS == 1 ) && ( configNUMBER_OF_CORES > 1 ) )
|
||||
void vTaskEnterCritical( void );
|
||||
#endif
|
||||
|
||||
|
@ -3731,7 +3745,7 @@ void vTaskInternalSetTimeOutState( TimeOut_t * const pxTimeOut ) PRIVILEGED_FUNC
|
|||
* It should be used in the implementation of portEXIT_CRITICAL if port is running a
|
||||
* multiple core FreeRTOS.
|
||||
*/
|
||||
#if ( ( portCRITICAL_NESTING_IN_TCB == 1 ) || ( configNUMBER_OF_CORES > 1 ) )
|
||||
#if !( ( portUSING_GRANULAR_LOCKS == 1 ) && ( configNUMBER_OF_CORES > 1 ) )
|
||||
void vTaskExitCritical( void );
|
||||
#endif
|
||||
|
||||
|
@ -3741,7 +3755,7 @@ void vTaskInternalSetTimeOutState( TimeOut_t * const pxTimeOut ) PRIVILEGED_FUNC
|
|||
* should be used in the implementation of portENTER_CRITICAL_FROM_ISR if port is
|
||||
* running a multiple core FreeRTOS.
|
||||
*/
|
||||
#if ( configNUMBER_OF_CORES > 1 )
|
||||
#if !( ( portUSING_GRANULAR_LOCKS == 1 ) && ( configNUMBER_OF_CORES > 1 ) )
|
||||
UBaseType_t vTaskEnterCriticalFromISR( void );
|
||||
#endif
|
||||
|
||||
|
@ -3751,10 +3765,18 @@ void vTaskInternalSetTimeOutState( TimeOut_t * const pxTimeOut ) PRIVILEGED_FUNC
|
|||
* should be used in the implementation of portEXIT_CRITICAL_FROM_ISR if port is
|
||||
* running a multiple core FreeRTOS.
|
||||
*/
|
||||
#if ( configNUMBER_OF_CORES > 1 )
|
||||
#if !( ( portUSING_GRANULAR_LOCKS == 1 ) && ( configNUMBER_OF_CORES > 1 ) )
|
||||
void vTaskExitCriticalFromISR( UBaseType_t uxSavedInterruptStatus );
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Checks whether a yield is required after taskUNLOCK_DATA_GROUP() returns.
|
||||
* To be called while data group is locked.
|
||||
*/
|
||||
#if ( ( portUSING_GRANULAR_LOCKS == 1 ) && ( configNUMBER_OF_CORES > 1 ) )
|
||||
BaseType_t xTaskUnlockCanYield( void );
|
||||
#endif /* #if ( ( portUSING_GRANULAR_LOCKS == 1 ) && ( configNUMBER_OF_CORES > 1 ) ) */
|
||||
|
||||
#if ( portUSING_MPU_WRAPPERS == 1 )
|
||||
|
||||
/*
|
||||
|
|
103
tasks.c
103
tasks.c
|
@ -504,7 +504,7 @@ PRIVILEGED_DATA static volatile TickType_t xTickCount = ( TickType_t ) configINI
|
|||
PRIVILEGED_DATA static volatile UBaseType_t uxTopReadyPriority = tskIDLE_PRIORITY;
|
||||
PRIVILEGED_DATA static volatile BaseType_t xSchedulerRunning = pdFALSE;
|
||||
PRIVILEGED_DATA static volatile TickType_t xPendedTicks = ( TickType_t ) 0U;
|
||||
PRIVILEGED_DATA static volatile BaseType_t xYieldPendings[ configNUMBER_OF_CORES ] = { pdFALSE };
|
||||
PRIVILEGED_DATA volatile BaseType_t xYieldPendings[ configNUMBER_OF_CORES ] = { pdFALSE };
|
||||
PRIVILEGED_DATA static volatile BaseType_t xNumOfOverflows = ( BaseType_t ) 0;
|
||||
PRIVILEGED_DATA static UBaseType_t uxTaskNumber = ( UBaseType_t ) 0U;
|
||||
PRIVILEGED_DATA static volatile TickType_t xNextTaskUnblockTime = ( TickType_t ) 0U; /* Initialised to portMAX_DELAY before the scheduler starts. */
|
||||
|
@ -538,6 +538,11 @@ PRIVILEGED_DATA static volatile configRUN_TIME_COUNTER_TYPE ulTotalRunTime[ conf
|
|||
|
||||
#endif
|
||||
|
||||
#if ( ( portUSING_GRANULAR_LOCKS == 1 ) && ( configNUMBER_OF_CORES > 1 ) )
|
||||
PRIVILEGED_DATA static portSPINLOCK_TYPE xTaskSpinlock = portINIT_KERNEL_TASK_SPINLOCK_STATIC;
|
||||
PRIVILEGED_DATA static portSPINLOCK_TYPE xISRSpinlock = portINIT_KERNEL_ISR_SPINLOCK_STATIC;
|
||||
#endif /* #if ( ( portUSING_GRANULAR_LOCKS == 1 ) && ( configNUMBER_OF_CORES > 1 ) ) */
|
||||
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
/* File private functions. --------------------------------*/
|
||||
|
@ -547,14 +552,14 @@ PRIVILEGED_DATA static volatile configRUN_TIME_COUNTER_TYPE ulTotalRunTime[ conf
|
|||
*/
|
||||
static BaseType_t prvCreateIdleTasks( void );
|
||||
|
||||
#if ( configNUMBER_OF_CORES > 1 )
|
||||
#if ( ( portUSING_GRANULAR_LOCKS == 0 ) && ( configNUMBER_OF_CORES > 1 ) )
|
||||
|
||||
/*
|
||||
* Checks to see if another task moved the current task out of the ready
|
||||
* list while it was waiting to enter a critical section and yields, if so.
|
||||
*/
|
||||
static void prvCheckForRunStateChange( void );
|
||||
#endif /* #if ( configNUMBER_OF_CORES > 1 ) */
|
||||
#endif /* #if ( ( portUSING_GRANULAR_LOCKS == 0 ) && ( configNUMBER_OF_CORES > 1 ) ) */
|
||||
|
||||
#if ( configNUMBER_OF_CORES > 1 )
|
||||
|
||||
|
@ -818,7 +823,7 @@ static void prvAddNewTaskToReadyList( TCB_t * pxNewTCB ) PRIVILEGED_FUNCTION;
|
|||
#endif /* #if ( ( configUSE_TRACE_FACILITY == 1 ) && ( configUSE_STATS_FORMATTING_FUNCTIONS > 0 ) ) */
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
#if ( configNUMBER_OF_CORES > 1 )
|
||||
#if ( ( portUSING_GRANULAR_LOCKS == 0 ) && ( configNUMBER_OF_CORES > 1 ) )
|
||||
static void prvCheckForRunStateChange( void )
|
||||
{
|
||||
UBaseType_t uxPrevCriticalNesting;
|
||||
|
@ -882,7 +887,7 @@ static void prvAddNewTaskToReadyList( TCB_t * pxNewTCB ) PRIVILEGED_FUNCTION;
|
|||
}
|
||||
}
|
||||
}
|
||||
#endif /* #if ( configNUMBER_OF_CORES > 1 ) */
|
||||
#endif /* #if ( ( portUSING_GRANULAR_LOCKS == 0 ) && ( configNUMBER_OF_CORES > 1 ) ) */
|
||||
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
|
@ -3905,7 +3910,24 @@ void vTaskSuspendAll( void )
|
|||
* do not otherwise exhibit real time behaviour. */
|
||||
portSOFTWARE_BARRIER();
|
||||
|
||||
portGET_TASK_LOCK( xCoreID );
|
||||
#if ( portUSING_GRANULAR_LOCKS == 1 )
|
||||
{
|
||||
portGET_SPINLOCK( &xTaskSpinlock );
|
||||
portGET_SPINLOCK( &xISRSpinlock );
|
||||
|
||||
/* Increment xPreemptionDisable to prevent preemption and also
|
||||
* track whether to yield in xTaskResumeAll(). */
|
||||
pxCurrentTCBs[ portGET_CORE_ID() ]->xPreemptionDisable++;
|
||||
|
||||
/* The scheduler is suspended if uxSchedulerSuspended is non-zero. An increment
|
||||
* is used to allow calls to vTaskSuspendAll() to nest. */
|
||||
++uxSchedulerSuspended;
|
||||
|
||||
portRELEASE_SPINLOCK( &xISRSpinlock );
|
||||
}
|
||||
#else /* #if ( portUSING_GRANULAR_LOCKS == 1 ) */
|
||||
{
|
||||
portGET_TASK_LOCK();
|
||||
|
||||
/* uxSchedulerSuspended is increased after prvCheckForRunStateChange. The
|
||||
* purpose is to prevent altering the variable when fromISR APIs are readying
|
||||
|
@ -3919,17 +3941,14 @@ void vTaskSuspendAll( void )
|
|||
mtCOVERAGE_TEST_MARKER();
|
||||
}
|
||||
|
||||
/* Query the coreID again as prvCheckForRunStateChange may have
|
||||
* caused the task to get scheduled on a different core. The correct
|
||||
* task lock for the core is acquired in prvCheckForRunStateChange. */
|
||||
xCoreID = ( BaseType_t ) portGET_CORE_ID();
|
||||
|
||||
portGET_ISR_LOCK( xCoreID );
|
||||
portGET_ISR_LOCK();
|
||||
|
||||
/* The scheduler is suspended if uxSchedulerSuspended is non-zero. An increment
|
||||
* is used to allow calls to vTaskSuspendAll() to nest. */
|
||||
++uxSchedulerSuspended;
|
||||
portRELEASE_ISR_LOCK( xCoreID );
|
||||
portRELEASE_ISR_LOCK();
|
||||
}
|
||||
#endif /* #if ( portUSING_GRANULAR_LOCKS == 1 ) */
|
||||
|
||||
portCLEAR_INTERRUPT_MASK( ulState );
|
||||
}
|
||||
|
@ -4034,7 +4053,24 @@ BaseType_t xTaskResumeAll( void )
|
|||
configASSERT( uxSchedulerSuspended != 0U );
|
||||
|
||||
uxSchedulerSuspended = ( UBaseType_t ) ( uxSchedulerSuspended - 1U );
|
||||
portRELEASE_TASK_LOCK( xCoreID );
|
||||
#if ( ( portUSING_GRANULAR_LOCKS == 1 ) && ( configNUMBER_OF_CORES > 1 ) )
|
||||
{
|
||||
configASSERT( pxCurrentTCBs[ portGET_CORE_ID() ]->xPreemptionDisable > 0 );
|
||||
|
||||
/* Decrement xPreemptionDisable. If 0, it means this we are not
|
||||
* in a nested suspension scenario, thus this function and yield
|
||||
* if necessary. */
|
||||
pxCurrentTCBs[ portGET_CORE_ID() ]->xPreemptionDisable--;
|
||||
|
||||
/* Release the kernel's task spinlock that was held throughout
|
||||
* the kernel suspension. */
|
||||
portRELEASE_SPINLOCK( &xTaskSpinlock );
|
||||
}
|
||||
#else /* #if ( ( portUSING_GRANULAR_LOCKS == 1 ) && ( configNUMBER_OF_CORES > 1 ) ) */
|
||||
{
|
||||
portRELEASE_TASK_LOCK();
|
||||
}
|
||||
#endif /* #if ( ( portUSING_GRANULAR_LOCKS == 1 ) && ( configNUMBER_OF_CORES > 1 ) ) */
|
||||
|
||||
if( uxSchedulerSuspended == ( UBaseType_t ) 0U )
|
||||
{
|
||||
|
@ -7023,7 +7059,7 @@ static void prvResetNextTaskUnblockTime( void )
|
|||
#endif /* #if ( ( portCRITICAL_NESTING_IN_TCB == 1 ) && ( configNUMBER_OF_CORES == 1 ) ) */
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
#if ( configNUMBER_OF_CORES > 1 )
|
||||
#if ( ( portUSING_GRANULAR_LOCKS == 0 ) && ( configNUMBER_OF_CORES > 1 ) )
|
||||
|
||||
void vTaskEnterCritical( void )
|
||||
{
|
||||
|
@ -7072,11 +7108,10 @@ static void prvResetNextTaskUnblockTime( void )
|
|||
traceRETURN_vTaskEnterCritical();
|
||||
}
|
||||
|
||||
#endif /* #if ( configNUMBER_OF_CORES > 1 ) */
|
||||
|
||||
#endif /* #if ( ( portUSING_GRANULAR_LOCKS == 0 ) && ( configNUMBER_OF_CORES > 1 ) ) */
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
#if ( configNUMBER_OF_CORES > 1 )
|
||||
#if ( ( portUSING_GRANULAR_LOCKS == 0 ) && ( configNUMBER_OF_CORES > 1 ) )
|
||||
|
||||
UBaseType_t vTaskEnterCriticalFromISR( void )
|
||||
{
|
||||
|
@ -7106,7 +7141,7 @@ static void prvResetNextTaskUnblockTime( void )
|
|||
return uxSavedInterruptStatus;
|
||||
}
|
||||
|
||||
#endif /* #if ( configNUMBER_OF_CORES > 1 ) */
|
||||
#endif /* #if ( ( portUSING_GRANULAR_LOCKS == 0 ) && ( configNUMBER_OF_CORES > 1 ) ) */
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
#if ( ( portCRITICAL_NESTING_IN_TCB == 1 ) && ( configNUMBER_OF_CORES == 1 ) )
|
||||
|
@ -7154,7 +7189,7 @@ static void prvResetNextTaskUnblockTime( void )
|
|||
#endif /* #if ( ( portCRITICAL_NESTING_IN_TCB == 1 ) && ( configNUMBER_OF_CORES == 1 ) ) */
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
#if ( configNUMBER_OF_CORES > 1 )
|
||||
#if ( ( portUSING_GRANULAR_LOCKS == 0 ) && ( configNUMBER_OF_CORES > 1 ) )
|
||||
|
||||
void vTaskExitCritical( void )
|
||||
{
|
||||
|
@ -7214,10 +7249,10 @@ static void prvResetNextTaskUnblockTime( void )
|
|||
traceRETURN_vTaskExitCritical();
|
||||
}
|
||||
|
||||
#endif /* #if ( configNUMBER_OF_CORES > 1 ) */
|
||||
#endif /* #if ( ( portUSING_GRANULAR_LOCKS == 0 ) && ( configNUMBER_OF_CORES > 1 ) ) */
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
#if ( configNUMBER_OF_CORES > 1 )
|
||||
#if ( ( portUSING_GRANULAR_LOCKS == 0 ) && ( configNUMBER_OF_CORES > 1 ) )
|
||||
|
||||
void vTaskExitCriticalFromISR( UBaseType_t uxSavedInterruptStatus )
|
||||
{
|
||||
|
@ -7260,7 +7295,29 @@ static void prvResetNextTaskUnblockTime( void )
|
|||
traceRETURN_vTaskExitCriticalFromISR();
|
||||
}
|
||||
|
||||
#endif /* #if ( configNUMBER_OF_CORES > 1 ) */
|
||||
#endif /* #if ( ( portUSING_GRANULAR_LOCKS == 0 ) && ( configNUMBER_OF_CORES > 1 ) ) */
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
#if ( ( portUSING_GRANULAR_LOCKS == 1 ) && ( configNUMBER_OF_CORES > 1 ) )
|
||||
|
||||
BaseType_t xTaskUnlockCanYield( void )
|
||||
{
|
||||
BaseType_t xReturn;
|
||||
BaseType_t xCoreID = portGET_CORE_ID();
|
||||
|
||||
if( ( xYieldPendings[ xCoreID ] == pdTRUE ) && ( uxSchedulerSuspended == pdFALSE ) && ( pxCurrentTCBs[ xCoreID ]->xPreemptionDisable == pdFALSE ) )
|
||||
{
|
||||
xReturn = pdTRUE;
|
||||
}
|
||||
else
|
||||
{
|
||||
xReturn = pdFALSE;
|
||||
}
|
||||
|
||||
return xReturn;
|
||||
}
|
||||
|
||||
#endif /* #if ( ( portUSING_GRANULAR_LOCKS == 1 ) && ( configNUMBER_OF_CORES > 1 ) ) */
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
#if ( configUSE_STATS_FORMATTING_FUNCTIONS > 0 )
|
||||
|
|
Loading…
Reference in a new issue