mirror of
https://github.com/FreeRTOS/FreeRTOS-Kernel.git
synced 2025-11-09 21:22:35 -05:00
Merge fb77de7c81 into 684b34ca8d
This commit is contained in:
commit
02f0c4f095
8 changed files with 2091 additions and 722 deletions
|
|
@ -369,6 +369,10 @@
|
|||
#define portCRITICAL_NESTING_IN_TCB 0
|
||||
#endif
|
||||
|
||||
#ifndef portUSING_GRANULAR_LOCKS
|
||||
#define portUSING_GRANULAR_LOCKS 0
|
||||
#endif
|
||||
|
||||
#ifndef configMAX_TASK_NAME_LEN
|
||||
#define configMAX_TASK_NAME_LEN 16
|
||||
#endif
|
||||
|
|
@ -454,44 +458,68 @@
|
|||
|
||||
#ifndef portRELEASE_TASK_LOCK
|
||||
|
||||
#if ( configNUMBER_OF_CORES == 1 )
|
||||
#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 */
|
||||
|
||||
#ifndef portGET_TASK_LOCK
|
||||
|
||||
#if ( configNUMBER_OF_CORES == 1 )
|
||||
#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 */
|
||||
|
||||
#ifndef portRELEASE_ISR_LOCK
|
||||
|
||||
#if ( configNUMBER_OF_CORES == 1 )
|
||||
#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 */
|
||||
|
||||
#ifndef portGET_ISR_LOCK
|
||||
|
||||
#if ( configNUMBER_OF_CORES == 1 )
|
||||
#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 */
|
||||
|
||||
#ifndef portRELEASE_SPINLOCK
|
||||
|
||||
#if ( ( portUSING_GRANULAR_LOCKS == 1 ) && ( configNUMBER_OF_CORES > 1 ) )
|
||||
#error portRELEASE_SPINLOCK is required for SMP with granular locking feature enabled
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
#ifndef portGET_SPINLOCK
|
||||
|
||||
#if ( ( portUSING_GRANULAR_LOCKS == 1 ) && ( configNUMBER_OF_CORES > 1 ) )
|
||||
#error portGET_SPINLOCK is required for SMP with granular locking feature enabled
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
#ifndef portCHECK_IF_IN_ISR
|
||||
|
||||
#if ( ( portUSING_GRANULAR_LOCKS == 1 ) && ( configNUMBER_OF_CORES > 1 ) )
|
||||
#error portCHECK_IF_IN_ISR is required for granular locking
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
#ifndef portENTER_CRITICAL_FROM_ISR
|
||||
|
||||
#if ( configNUMBER_OF_CORES > 1 )
|
||||
|
|
@ -508,6 +536,30 @@
|
|||
|
||||
#endif
|
||||
|
||||
#ifndef portSPINLOCK_TYPE
|
||||
|
||||
#if ( ( portUSING_GRANULAR_LOCKS == 1 ) && ( configNUMBER_OF_CORES > 1 ) )
|
||||
#error portSPINLOCK_TYPE is required for SMP with granular locking feature enabled
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
#ifndef portINIT_SPINLOCK
|
||||
|
||||
#if ( ( portUSING_GRANULAR_LOCKS == 1 ) && ( configNUMBER_OF_CORES > 1 ) )
|
||||
#error portINIT_SPINLOCK is required for SMP with granular locking feature enabled
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
#ifndef portINIT_SPINLOCK_STATIC
|
||||
|
||||
#if ( ( portUSING_GRANULAR_LOCKS == 1 ) && ( configNUMBER_OF_CORES > 1 ) )
|
||||
#error portINIT_SPINLOCK_STATIC is required for SMP with granular locking feature enabled
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
#ifndef configUSE_CORE_AFFINITY
|
||||
#define configUSE_CORE_AFFINITY 0
|
||||
#endif /* configUSE_CORE_AFFINITY */
|
||||
|
|
@ -2915,11 +2967,16 @@
|
|||
/* Either variables of tick type cannot be read atomically, or
|
||||
* portTICK_TYPE_IS_ATOMIC was not set - map the critical sections used when
|
||||
* the tick count is returned to the standard critical section macros. */
|
||||
#define portTICK_TYPE_ENTER_CRITICAL() portENTER_CRITICAL()
|
||||
#define portTICK_TYPE_EXIT_CRITICAL() portEXIT_CRITICAL()
|
||||
#if ( ( portUSING_GRANULAR_LOCKS == 1 ) && ( configNUMBER_OF_CORES > 1 ) )
|
||||
#define portTICK_TYPE_ENTER_CRITICAL() portENTER_CRITICAL_DATA_GROUP( &xTaskSpinlock, &xISRSpinlock )
|
||||
#define portTICK_TYPE_EXIT_CRITICAL() portEXIT_CRITICAL_DATA_GROUP( &xTaskSpinlock, &xISRSpinlock )
|
||||
#else /* #if ( ( portUSING_GRANULAR_LOCKS == 1 ) && ( configNUMBER_OF_CORES > 1 ) ) */
|
||||
#define portTICK_TYPE_ENTER_CRITICAL() portENTER_CRITICAL()
|
||||
#define portTICK_TYPE_EXIT_CRITICAL() portEXIT_CRITICAL()
|
||||
#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. */
|
||||
|
|
@ -3179,7 +3236,10 @@ typedef struct xSTATIC_TCB
|
|||
#endif
|
||||
uint8_t ucDummy7[ configMAX_TASK_NAME_LEN ];
|
||||
#if ( configUSE_TASK_PREEMPTION_DISABLE == 1 )
|
||||
BaseType_t xDummy25;
|
||||
UBaseType_t xDummy25;
|
||||
#endif
|
||||
#if ( configUSE_TASK_PREEMPTION_DISABLE == 1 )
|
||||
BaseType_t xDummy26;
|
||||
#endif
|
||||
#if ( ( portSTACK_GROWTH > 0 ) || ( configRECORD_STACK_HIGH_ADDRESS == 1 ) )
|
||||
void * pxDummy8;
|
||||
|
|
@ -3261,6 +3321,10 @@ typedef struct xSTATIC_QUEUE
|
|||
UBaseType_t uxDummy8;
|
||||
uint8_t ucDummy9;
|
||||
#endif
|
||||
|
||||
#if ( ( portUSING_GRANULAR_LOCKS == 1 ) && ( configNUMBER_OF_CORES > 1 ) )
|
||||
portSPINLOCK_TYPE xDummySpinlock[ 2 ];
|
||||
#endif /* #if ( ( portUSING_GRANULAR_LOCKS == 1 ) && ( configNUMBER_OF_CORES > 1 ) ) */
|
||||
} StaticQueue_t;
|
||||
typedef StaticQueue_t StaticSemaphore_t;
|
||||
|
||||
|
|
@ -3290,6 +3354,10 @@ typedef struct xSTATIC_EVENT_GROUP
|
|||
#if ( ( configSUPPORT_STATIC_ALLOCATION == 1 ) && ( configSUPPORT_DYNAMIC_ALLOCATION == 1 ) )
|
||||
uint8_t ucDummy4;
|
||||
#endif
|
||||
|
||||
#if ( ( portUSING_GRANULAR_LOCKS == 1 ) && ( configNUMBER_OF_CORES > 1 ) )
|
||||
portSPINLOCK_TYPE xDummySpinlock[ 2 ];
|
||||
#endif /* #if ( ( portUSING_GRANULAR_LOCKS == 1 ) && ( configNUMBER_OF_CORES > 1 ) ) */
|
||||
} StaticEventGroup_t;
|
||||
|
||||
/*
|
||||
|
|
@ -3345,6 +3413,9 @@ typedef struct xSTATIC_STREAM_BUFFER
|
|||
void * pvDummy5[ 2 ];
|
||||
#endif
|
||||
UBaseType_t uxDummy6;
|
||||
#if ( ( portUSING_GRANULAR_LOCKS == 1 ) && ( configNUMBER_OF_CORES > 1 ) )
|
||||
portSPINLOCK_TYPE xDummySpinlock[ 2 ];
|
||||
#endif /* #if ( ( portUSING_GRANULAR_LOCKS == 1 ) && ( configNUMBER_OF_CORES > 1 ) ) */
|
||||
} StaticStreamBuffer_t;
|
||||
|
||||
/* Message buffers are built on stream buffers. */
|
||||
|
|
|
|||
112
include/task.h
112
include/task.h
|
|
@ -283,6 +283,110 @@ typedef enum
|
|||
/* Checks if core ID is valid. */
|
||||
#define taskVALID_CORE_ID( xCoreID ) ( ( ( ( ( BaseType_t ) 0 <= ( xCoreID ) ) && ( ( xCoreID ) < ( BaseType_t ) configNUMBER_OF_CORES ) ) ) ? ( pdTRUE ) : ( pdFALSE ) )
|
||||
|
||||
/**
|
||||
* task. h
|
||||
*
|
||||
* Macro to enter a data group critical section.
|
||||
*
|
||||
* \defgroup taskDATA_GROUP_ENTER_CRITICAL taskDATA_GROUP_ENTER_CRITICAL
|
||||
* \ingroup GranularLocks
|
||||
*/
|
||||
#if ( portUSING_GRANULAR_LOCKS == 1 )
|
||||
#define taskDATA_GROUP_ENTER_CRITICAL( pxTaskSpinlock, pxISRSpinlock ) \
|
||||
do { \
|
||||
/* Disable preemption to avoid task state changes during the critical section. */ \
|
||||
vTaskPreemptionDisable( NULL ); \
|
||||
{ \
|
||||
const BaseType_t xCoreID = ( BaseType_t ) portGET_CORE_ID(); \
|
||||
/* Task spinlock is always taken first */ \
|
||||
portGET_SPINLOCK( xCoreID, ( portSPINLOCK_TYPE * ) pxTaskSpinlock ); \
|
||||
/* Disable interrupts */ \
|
||||
portDISABLE_INTERRUPTS(); \
|
||||
/* Take the ISR spinlock next */ \
|
||||
portGET_SPINLOCK( xCoreID, ( portSPINLOCK_TYPE * ) pxISRSpinlock ); \
|
||||
/* Increment the critical nesting count */ \
|
||||
portINCREMENT_CRITICAL_NESTING_COUNT( xCoreID ); \
|
||||
} \
|
||||
} while( 0 )
|
||||
#endif /* #if ( portUSING_GRANULAR_LOCKS == 1 ) */
|
||||
|
||||
/**
|
||||
* task. h
|
||||
*
|
||||
* Macro to enter a data group critical section from an interrupt.
|
||||
*
|
||||
* \defgroup taskDATA_GROUP_ENTER_CRITICAL_FROM_ISR taskDATA_GROUP_ENTER_CRITICAL_FROM_ISR
|
||||
* \ingroup GranularLocks
|
||||
*/
|
||||
#if ( portUSING_GRANULAR_LOCKS == 1 )
|
||||
#define taskDATA_GROUP_ENTER_CRITICAL_FROM_ISR( pxISRSpinlock, puxSavedInterruptStatus ) \
|
||||
do { \
|
||||
*( puxSavedInterruptStatus ) = portSET_INTERRUPT_MASK_FROM_ISR(); \
|
||||
const BaseType_t xCoreID = ( BaseType_t ) portGET_CORE_ID(); \
|
||||
/* Take the ISR spinlock */ \
|
||||
portGET_SPINLOCK( xCoreID, ( portSPINLOCK_TYPE * ) pxISRSpinlock ); \
|
||||
/* Increment the critical nesting count */ \
|
||||
portINCREMENT_CRITICAL_NESTING_COUNT( xCoreID ); \
|
||||
} while( 0 )
|
||||
#endif /* #if ( portUSING_GRANULAR_LOCKS == 1 ) */
|
||||
|
||||
/**
|
||||
* task. h
|
||||
*
|
||||
* Macro to exit a data group critical section.
|
||||
*
|
||||
* \defgroup taskDATA_GROUP_EXIT_CRITICAL taskDATA_GROUP_EXIT_CRITICAL
|
||||
* \ingroup GranularLocks
|
||||
*/
|
||||
#if ( portUSING_GRANULAR_LOCKS == 1 )
|
||||
#define taskDATA_GROUP_EXIT_CRITICAL( pxTaskSpinlock, pxISRSpinlock ) \
|
||||
do { \
|
||||
const BaseType_t xCoreID = ( BaseType_t ) portGET_CORE_ID(); \
|
||||
configASSERT( portGET_CRITICAL_NESTING_COUNT( xCoreID ) > 0U ); \
|
||||
/* Release the ISR spinlock */ \
|
||||
portRELEASE_SPINLOCK( xCoreID, ( portSPINLOCK_TYPE * ) pxISRSpinlock ); \
|
||||
/* Release the task spinlock */ \
|
||||
portRELEASE_SPINLOCK( xCoreID, ( portSPINLOCK_TYPE * ) pxTaskSpinlock ); \
|
||||
/* Decrement the critical nesting count */ \
|
||||
portDECREMENT_CRITICAL_NESTING_COUNT( xCoreID ); \
|
||||
/* Enable interrupts only if the critical nesting count is 0 */ \
|
||||
if( portGET_CRITICAL_NESTING_COUNT( xCoreID ) == 0 ) \
|
||||
{ \
|
||||
portENABLE_INTERRUPTS(); \
|
||||
} \
|
||||
else \
|
||||
{ \
|
||||
mtCOVERAGE_TEST_MARKER(); \
|
||||
} \
|
||||
/* Re-enable preemption */ \
|
||||
vTaskPreemptionEnable( NULL ); \
|
||||
} while( 0 )
|
||||
#endif /* #if ( portUSING_GRANULAR_LOCKS == 1 ) */
|
||||
|
||||
/**
|
||||
* task. h
|
||||
*
|
||||
* Macro to exit a data group critical section from an interrupt.
|
||||
*
|
||||
* \defgroup taskDATA_GROUP_EXIT_CRITICAL_FROM_ISR taskDATA_GROUP_EXIT_CRITICAL_FROM_ISR
|
||||
* \ingroup GranularLocks
|
||||
*/
|
||||
#if ( portUSING_GRANULAR_LOCKS == 1 )
|
||||
#define taskDATA_GROUP_EXIT_CRITICAL_FROM_ISR( uxSavedInterruptStatus, pxISRSpinlock ) \
|
||||
do { \
|
||||
const BaseType_t xCoreID = ( BaseType_t ) portGET_CORE_ID(); \
|
||||
configASSERT( portGET_CRITICAL_NESTING_COUNT( xCoreID ) > 0U ); \
|
||||
/* Decrement the critical nesting count */ \
|
||||
portDECREMENT_CRITICAL_NESTING_COUNT( xCoreID ); \
|
||||
/* Release the ISR spinlock */ \
|
||||
portRELEASE_SPINLOCK( xCoreID, ( portSPINLOCK_TYPE * ) pxISRSpinlock ); \
|
||||
if( portGET_CRITICAL_NESTING_COUNT( xCoreID ) == 0 ) \
|
||||
{ \
|
||||
portCLEAR_INTERRUPT_MASK_FROM_ISR( uxSavedInterruptStatus ); \
|
||||
} \
|
||||
} while( 0 )
|
||||
#endif /* #if ( portUSING_GRANULAR_LOCKS == 1 ) */
|
||||
|
||||
/*-----------------------------------------------------------
|
||||
* TASK CREATION API
|
||||
*----------------------------------------------------------*/
|
||||
|
|
@ -3755,6 +3859,14 @@ void vTaskInternalSetTimeOutState( TimeOut_t * const pxTimeOut ) PRIVILEGED_FUNC
|
|||
void vTaskExitCriticalFromISR( UBaseType_t uxSavedInterruptStatus );
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Checks whether a yield is required after portUNLOCK_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 )
|
||||
|
||||
/*
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue