remove(freertos-smp): Remove support for light-weight critical sections

This commit is contained in:
Sudeep Mohanty 2025-08-21 09:46:03 +02:00
parent 9000208ecf
commit 592177f42e
3 changed files with 4 additions and 184 deletions

View file

@ -2958,10 +2958,6 @@
#error configUSE_PORT_OPTIMISED_TASK_SELECTION is not supported in SMP FreeRTOS
#endif
#ifndef configLIGHTWEIGHT_CRITICAL_SECTION
#define configLIGHTWEIGHT_CRITICAL_SECTION 0
#endif
#ifndef configINITIAL_TICK_COUNT
#define configINITIAL_TICK_COUNT 0
#endif

View file

@ -3914,22 +3914,6 @@ void vTaskInternalSetTimeOutState( TimeOut_t * const pxTimeOut ) PRIVILEGED_FUNC
void vTaskExitCriticalFromISR( UBaseType_t uxSavedInterruptStatus );
#endif
/*
* This function is only intended for use when disabling or enabling preemption of a task.
* This function takes only the kernel ISR lock, not the task lock.
*/
#if ( configLIGHTWEIGHT_CRITICAL_SECTION == 1 )
void vKernelLightWeightEnterCritical( void );
#endif
/*
* This function is only intended for use when disabling or enabling preemption of a task.
* This function releases only the kernel ISR lock, not the task lock.
*/
#if ( configLIGHTWEIGHT_CRITICAL_SECTION == 1 )
void vKernelLightWeightExitCritical( void );
#endif
#if ( portUSING_MPU_WRAPPERS == 1 )
/*

168
tasks.c
View file

@ -629,15 +629,6 @@ static BaseType_t prvCreateIdleTasks( void );
static void prvCheckForRunStateChange( void );
#endif /* #if ( configNUMBER_OF_CORES > 1 ) */
#if ( configLIGHTWEIGHT_CRITICAL_SECTION == 1 )
/*
* Checks to see if another task moved the current task out of the ready
* list while it was waiting to enter a lightweight critical section and yields, if so.
*/
static void prvLightWeightCheckForRunStateChange( void );
#endif /* #if ( configLIGHTWEIGHT_CRITICAL_SECTION == 1 ) */
#if ( configNUMBER_OF_CORES > 1 )
/*
@ -976,67 +967,6 @@ static void prvAddNewTaskToReadyList( TCB_t * pxNewTCB ) PRIVILEGED_FUNCTION;
/*-----------------------------------------------------------*/
#if ( configLIGHTWEIGHT_CRITICAL_SECTION == 1 )
static void prvLightWeightCheckForRunStateChange( void )
{
const TCB_t * pxThisTCB;
BaseType_t xCoreID = ( BaseType_t ) portGET_CORE_ID();
/* This must only be called from within a task. */
portASSERT_IF_IN_ISR();
/* This function is always called with interrupts disabled
* so this is safe. */
pxThisTCB = pxCurrentTCBs[ xCoreID ];
while( pxThisTCB->xTaskRunState == taskTASK_SCHEDULED_TO_YIELD )
{
UBaseType_t uxPrevCriticalNesting;
/* We are only here if we just entered a critical section
* or if we just suspended the scheduler, and another task
* has requested that we yield.
*
* This is slightly complicated since we need to save and restore
* the suspension and critical nesting counts, as well as release
* and reacquire the correct locks. And then, do it all over again
* if our state changed again during the reacquisition. */
uxPrevCriticalNesting = portGET_CRITICAL_NESTING_COUNT( xCoreID );
if( uxPrevCriticalNesting > 0U )
{
portSET_CRITICAL_NESTING_COUNT( xCoreID, 0U );
kernelRELEASE_ISR_LOCK( xCoreID );
}
else
{
/* The scheduler is suspended. uxSchedulerSuspended is updated
* only when the task is not requested to yield. */
mtCOVERAGE_TEST_MARKER();
}
portMEMORY_BARRIER();
portENABLE_INTERRUPTS();
/* Enabling interrupts should cause this core to immediately service
* the pending interrupt and yield. After servicing the pending interrupt,
* the task needs to re-evaluate its run state within this loop, as
* other cores may have requested this task to yield, potentially altering
* its run state. */
portDISABLE_INTERRUPTS();
xCoreID = ( BaseType_t ) portGET_CORE_ID();
kernelGET_ISR_LOCK( xCoreID );
portSET_CRITICAL_NESTING_COUNT( xCoreID, uxPrevCriticalNesting );
}
}
#endif /* #if ( configLIGHTWEIGHT_CRITICAL_SECTION == 1 ) */
/*-----------------------------------------------------------*/
#if ( configNUMBER_OF_CORES > 1 )
static void prvYieldForTask( const TCB_t * pxTCB )
{
@ -3342,11 +3272,7 @@ static void prvInitialiseNewTask( TaskFunction_t pxTaskCode,
traceENTER_vTaskPreemptionDisable( xTask );
#if ( configLIGHTWEIGHT_CRITICAL_SECTION == 1 )
vKernelLightWeightEnterCritical();
#else
kernelENTER_CRITICAL();
#endif
kernelENTER_CRITICAL();
{
if( xSchedulerRunning != pdFALSE )
{
@ -3360,11 +3286,7 @@ static void prvInitialiseNewTask( TaskFunction_t pxTaskCode,
mtCOVERAGE_TEST_MARKER();
}
}
#if ( configLIGHTWEIGHT_CRITICAL_SECTION == 1 )
vKernelLightWeightExitCritical();
#else
kernelEXIT_CRITICAL();
#endif
kernelEXIT_CRITICAL();
traceRETURN_vTaskPreemptionDisable();
}
@ -3380,11 +3302,7 @@ static void prvInitialiseNewTask( TaskFunction_t pxTaskCode,
UBaseType_t uxDeferredAction = 0U;
BaseType_t xAlreadyYielded = pdFALSE;
#if ( configLIGHTWEIGHT_CRITICAL_SECTION == 1 )
vKernelLightWeightEnterCritical();
#else
kernelENTER_CRITICAL();
#endif
kernelENTER_CRITICAL();
{
if( xSchedulerRunning != pdFALSE )
{
@ -3423,11 +3341,7 @@ static void prvInitialiseNewTask( TaskFunction_t pxTaskCode,
mtCOVERAGE_TEST_MARKER();
}
}
#if ( configLIGHTWEIGHT_CRITICAL_SECTION == 1 )
vKernelLightWeightExitCritical();
#else
kernelEXIT_CRITICAL();
#endif
kernelEXIT_CRITICAL();
if( uxDeferredAction != 0U )
{
@ -7848,80 +7762,6 @@ static void prvResetNextTaskUnblockTime( void )
#endif /* #if ( configNUMBER_OF_CORES > 1 ) */
/*-----------------------------------------------------------*/
#if ( configLIGHTWEIGHT_CRITICAL_SECTION == 1 )
void vKernelLightWeightEnterCritical( void )
{
if( xSchedulerRunning != pdFALSE )
{
portDISABLE_INTERRUPTS();
{
const BaseType_t xCoreID = ( BaseType_t ) portGET_CORE_ID();
/* Get only the ISR lock, not the task lock */
kernelGET_ISR_LOCK( xCoreID );
portINCREMENT_CRITICAL_NESTING_COUNT( xCoreID );
if( portGET_CRITICAL_NESTING_COUNT( xCoreID ) == 1U )
{
prvLightWeightCheckForRunStateChange();
}
}
}
}
#endif /* #if ( configLIGHTWEIGHT_CRITICAL_SECTION == 1 ) */
/*-----------------------------------------------------------*/
#if ( configLIGHTWEIGHT_CRITICAL_SECTION == 1 )
void vKernelLightWeightExitCritical( void )
{
if( xSchedulerRunning != pdFALSE )
{
const BaseType_t xCoreID = ( BaseType_t ) portGET_CORE_ID();
if( portGET_CRITICAL_NESTING_COUNT( xCoreID ) > 0U )
{
BaseType_t xYieldCurrentTask;
if( ( xYieldPendings[ xCoreID ] == pdTRUE ) && ( uxSchedulerSuspended == pdFALSE )
#if ( configUSE_TASK_PREEMPTION_DISABLE == 1 )
&& ( pxCurrentTCBs[ xCoreID ]->uxPreemptionDisable == 0U ) &&
( pxCurrentTCBs[ xCoreID ]->uxDeferredStateChange == 0U )
#endif /* ( configUSE_TASK_PREEMPTION_DISABLE == 1 ) */
)
{
xYieldCurrentTask = pdTRUE;
}
else
{
xYieldCurrentTask = pdFALSE;
}
/* Release the ISR lock */
kernelRELEASE_ISR_LOCK( xCoreID );
portDECREMENT_CRITICAL_NESTING_COUNT( xCoreID );
/* If the critical nesting count is 0, enable interrupts */
if( portGET_CRITICAL_NESTING_COUNT( xCoreID ) == 0U )
{
portENABLE_INTERRUPTS();
if( xYieldCurrentTask != pdFALSE )
{
portYIELD();
}
}
}
}
}
#endif /* #if ( configLIGHTWEIGHT_CRITICAL_SECTION == 1 ) */
/*-----------------------------------------------------------*/
#if ( configUSE_STATS_FORMATTING_FUNCTIONS > 0 )
static char * prvWriteNameToBuffer( char * pcBuffer,