Skip to content

Updated tasks.c checks for scheduler suspension #670

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 8, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 18 additions & 18 deletions tasks.c
Original file line number Diff line number Diff line change
Expand Up @@ -387,7 +387,7 @@ const volatile UBaseType_t uxTopUsedPriority = configMAX_PRIORITIES - 1U;
* kernel to move the task from the pending ready list into the real ready list
* when the scheduler is unsuspended. The pending ready list itself can only be
* accessed from a critical section. */
PRIVILEGED_DATA static volatile UBaseType_t uxSchedulerSuspended = ( UBaseType_t ) pdFALSE;
PRIVILEGED_DATA static volatile UBaseType_t uxSchedulerSuspended = ( UBaseType_t ) 0U;

#if ( configGENERATE_RUN_TIME_STATS == 1 )

Expand Down Expand Up @@ -1200,7 +1200,7 @@ static void prvAddNewTaskToReadyList( TCB_t * pxNewTCB )
{
if( pxTCB == pxCurrentTCB )
{
configASSERT( uxSchedulerSuspended == 0 );
configASSERT( uxSchedulerSuspended == ( UBaseType_t ) 0U );
portYIELD_WITHIN_API();
}
else
Expand All @@ -1223,7 +1223,7 @@ static void prvAddNewTaskToReadyList( TCB_t * pxNewTCB )

configASSERT( pxPreviousWakeTime );
configASSERT( ( xTimeIncrement > 0U ) );
configASSERT( uxSchedulerSuspended == 0 );
configASSERT( uxSchedulerSuspended == ( UBaseType_t ) 0U );

vTaskSuspendAll();
{
Expand Down Expand Up @@ -1309,7 +1309,7 @@ static void prvAddNewTaskToReadyList( TCB_t * pxNewTCB )
/* A delay time of zero just forces a reschedule. */
if( xTicksToDelay > ( TickType_t ) 0U )
{
configASSERT( uxSchedulerSuspended == 0 );
configASSERT( uxSchedulerSuspended == ( UBaseType_t ) 0U );
vTaskSuspendAll();
{
traceTASK_DELAY();
Expand Down Expand Up @@ -1748,7 +1748,7 @@ static void prvAddNewTaskToReadyList( TCB_t * pxNewTCB )
if( xSchedulerRunning != pdFALSE )
{
/* The current task has just been suspended. */
configASSERT( uxSchedulerSuspended == 0 );
configASSERT( uxSchedulerSuspended == ( UBaseType_t ) 0U );
portYIELD_WITHIN_API();
}
else
Expand Down Expand Up @@ -1914,7 +1914,7 @@ static void prvAddNewTaskToReadyList( TCB_t * pxNewTCB )
traceTASK_RESUME_FROM_ISR( pxTCB );

/* Check the ready lists can be accessed. */
if( uxSchedulerSuspended == ( UBaseType_t ) pdFALSE )
if( uxSchedulerSuspended == ( UBaseType_t ) 0U )
{
/* Ready lists can be accessed so move the task from the
* suspended list to the ready list directly. */
Expand Down Expand Up @@ -2183,7 +2183,7 @@ BaseType_t xTaskResumeAll( void )

/* If uxSchedulerSuspended is zero then this function does not match a
* previous call to vTaskSuspendAll(). */
configASSERT( uxSchedulerSuspended );
configASSERT( uxSchedulerSuspended != ( UBaseType_t ) 0U );

/* It is possible that an ISR caused a task to be removed from an event
* list while the scheduler was suspended. If this was the case then the
Expand All @@ -2194,7 +2194,7 @@ BaseType_t xTaskResumeAll( void )
{
--uxSchedulerSuspended;

if( uxSchedulerSuspended == ( UBaseType_t ) pdFALSE )
if( uxSchedulerSuspended == ( UBaseType_t ) 0U )
{
if( uxCurrentNumberOfTasks > ( UBaseType_t ) 0U )
{
Expand Down Expand Up @@ -2642,7 +2642,7 @@ char * pcTaskGetName( TaskHandle_t xTaskToQuery ) /*lint !e971 Unqualified char
/* Arrange for xTickCount to reach xNextTaskUnblockTime in
* xTaskIncrementTick() when the scheduler resumes. This ensures
* that any delayed tasks are resumed at the correct time. */
configASSERT( uxSchedulerSuspended );
configASSERT( uxSchedulerSuspended != ( UBaseType_t ) 0U );
configASSERT( xTicksToJump != ( TickType_t ) 0 );

/* Prevent the tick interrupt modifying xPendedTicks simultaneously. */
Expand Down Expand Up @@ -2671,7 +2671,7 @@ BaseType_t xTaskCatchUpTicks( TickType_t xTicksToCatchUp )

/* Must not be called with the scheduler suspended as the implementation
* relies on xPendedTicks being wound down to 0 in xTaskResumeAll(). */
configASSERT( uxSchedulerSuspended == 0 );
configASSERT( uxSchedulerSuspended == ( UBaseType_t ) 0U );

/* Use xPendedTicks to mimic xTicksToCatchUp number of ticks occurring when
* the scheduler is suspended so the ticks are executed in xTaskResumeAll(). */
Expand Down Expand Up @@ -2780,7 +2780,7 @@ BaseType_t xTaskIncrementTick( void )
* tasks to be unblocked. */
traceTASK_INCREMENT_TICK( xTickCount );

if( uxSchedulerSuspended == ( UBaseType_t ) pdFALSE )
if( uxSchedulerSuspended == ( UBaseType_t ) 0U )
{
/* Minor optimisation. The tick count cannot change in this
* block. */
Expand Down Expand Up @@ -3060,7 +3060,7 @@ BaseType_t xTaskIncrementTick( void )

void vTaskSwitchContext( void )
{
if( uxSchedulerSuspended != ( UBaseType_t ) pdFALSE )
if( uxSchedulerSuspended != ( UBaseType_t ) 0U )
{
/* The scheduler is currently suspended - do not allow a context
* switch. */
Expand Down Expand Up @@ -3165,7 +3165,7 @@ void vTaskPlaceOnUnorderedEventList( List_t * pxEventList,

/* THIS FUNCTION MUST BE CALLED WITH THE SCHEDULER SUSPENDED. It is used by
* the event groups implementation. */
configASSERT( uxSchedulerSuspended != 0 );
configASSERT( uxSchedulerSuspended != ( UBaseType_t ) 0U );

/* Store the item value in the event list item. It is safe to access the
* event list item here as interrupts won't access the event list item of a
Expand Down Expand Up @@ -3240,7 +3240,7 @@ BaseType_t xTaskRemoveFromEventList( const List_t * const pxEventList )
configASSERT( pxUnblockedTCB );
listREMOVE_ITEM( &( pxUnblockedTCB->xEventListItem ) );

if( uxSchedulerSuspended == ( UBaseType_t ) pdFALSE )
if( uxSchedulerSuspended == ( UBaseType_t ) 0U )
{
listREMOVE_ITEM( &( pxUnblockedTCB->xStateListItem ) );
prvAddTaskToReadyList( pxUnblockedTCB );
Expand Down Expand Up @@ -3293,7 +3293,7 @@ void vTaskRemoveFromUnorderedEventList( ListItem_t * pxEventListItem,

/* THIS FUNCTION MUST BE CALLED WITH THE SCHEDULER SUSPENDED. It is used by
* the event flags implementation. */
configASSERT( uxSchedulerSuspended != pdFALSE );
configASSERT( uxSchedulerSuspended != ( UBaseType_t ) 0U );

/* Store the new item value in the event list. */
listSET_LIST_ITEM_VALUE( pxEventListItem, xItemValue | taskEVENT_LIST_ITEM_VALUE_IN_USE );
Expand Down Expand Up @@ -4093,7 +4093,7 @@ static void prvResetNextTaskUnblockTime( void )
}
else
{
if( uxSchedulerSuspended == ( UBaseType_t ) pdFALSE )
if( uxSchedulerSuspended == ( UBaseType_t ) 0U )
{
xReturn = taskSCHEDULER_RUNNING;
}
Expand Down Expand Up @@ -5113,7 +5113,7 @@ TickType_t uxTaskResetEventItemValue( void )
/* The task should not have been on an event list. */
configASSERT( listLIST_ITEM_CONTAINER( &( pxTCB->xEventListItem ) ) == NULL );

if( uxSchedulerSuspended == ( UBaseType_t ) pdFALSE )
if( uxSchedulerSuspended == ( UBaseType_t ) 0U )
{
listREMOVE_ITEM( &( pxTCB->xStateListItem ) );
prvAddTaskToReadyList( pxTCB );
Expand Down Expand Up @@ -5204,7 +5204,7 @@ TickType_t uxTaskResetEventItemValue( void )
/* The task should not have been on an event list. */
configASSERT( listLIST_ITEM_CONTAINER( &( pxTCB->xEventListItem ) ) == NULL );

if( uxSchedulerSuspended == ( UBaseType_t ) pdFALSE )
if( uxSchedulerSuspended == ( UBaseType_t ) 0U )
{
listREMOVE_ITEM( &( pxTCB->xStateListItem ) );
prvAddTaskToReadyList( pxTCB );
Expand Down