214
214
215
215
/*-----------------------------------------------------------*/
216
216
217
+ /* Check if the scheduler is suspended */
218
+ #define taskIS_SCHEDULER_SUSPENDED () ( uxSchedulerSuspended > ( UBaseType_t ) 0U )
219
+
220
+ /*-----------------------------------------------------------*/
221
+
217
222
/*
218
223
* Place the task represented by pxTCB into the appropriate ready list for
219
224
* the task. It is inserted at the end of the list.
@@ -387,7 +392,7 @@ const volatile UBaseType_t uxTopUsedPriority = configMAX_PRIORITIES - 1U;
387
392
* kernel to move the task from the pending ready list into the real ready list
388
393
* when the scheduler is unsuspended. The pending ready list itself can only be
389
394
* accessed from a critical section. */
390
- PRIVILEGED_DATA static volatile UBaseType_t uxSchedulerSuspended = ( UBaseType_t ) pdFALSE ;
395
+ PRIVILEGED_DATA static volatile UBaseType_t uxSchedulerSuspended = ( UBaseType_t ) 0U ;
391
396
392
397
#if ( configGENERATE_RUN_TIME_STATS == 1 )
393
398
@@ -1200,7 +1205,7 @@ static void prvAddNewTaskToReadyList( TCB_t * pxNewTCB )
1200
1205
{
1201
1206
if ( pxTCB == pxCurrentTCB )
1202
1207
{
1203
- configASSERT ( uxSchedulerSuspended == 0 );
1208
+ configASSERT ( ! taskIS_SCHEDULER_SUSPENDED () );
1204
1209
portYIELD_WITHIN_API ();
1205
1210
}
1206
1211
else
@@ -1223,7 +1228,7 @@ static void prvAddNewTaskToReadyList( TCB_t * pxNewTCB )
1223
1228
1224
1229
configASSERT ( pxPreviousWakeTime );
1225
1230
configASSERT ( ( xTimeIncrement > 0U ) );
1226
- configASSERT ( uxSchedulerSuspended == 0 );
1231
+ configASSERT ( ! taskIS_SCHEDULER_SUSPENDED () );
1227
1232
1228
1233
vTaskSuspendAll ();
1229
1234
{
@@ -1309,7 +1314,7 @@ static void prvAddNewTaskToReadyList( TCB_t * pxNewTCB )
1309
1314
/* A delay time of zero just forces a reschedule. */
1310
1315
if ( xTicksToDelay > ( TickType_t ) 0U )
1311
1316
{
1312
- configASSERT ( uxSchedulerSuspended == 0 );
1317
+ configASSERT ( ! taskIS_SCHEDULER_SUSPENDED () );
1313
1318
vTaskSuspendAll ();
1314
1319
{
1315
1320
traceTASK_DELAY ();
@@ -1748,7 +1753,7 @@ static void prvAddNewTaskToReadyList( TCB_t * pxNewTCB )
1748
1753
if ( xSchedulerRunning != pdFALSE )
1749
1754
{
1750
1755
/* The current task has just been suspended. */
1751
- configASSERT ( uxSchedulerSuspended == 0 );
1756
+ configASSERT ( ! taskIS_SCHEDULER_SUSPENDED () );
1752
1757
portYIELD_WITHIN_API ();
1753
1758
}
1754
1759
else
@@ -1914,7 +1919,7 @@ static void prvAddNewTaskToReadyList( TCB_t * pxNewTCB )
1914
1919
traceTASK_RESUME_FROM_ISR ( pxTCB );
1915
1920
1916
1921
/* Check the ready lists can be accessed. */
1917
- if ( uxSchedulerSuspended == ( UBaseType_t ) pdFALSE )
1922
+ if ( ! taskIS_SCHEDULER_SUSPENDED () )
1918
1923
{
1919
1924
/* Ready lists can be accessed so move the task from the
1920
1925
* suspended list to the ready list directly. */
@@ -2183,7 +2188,7 @@ BaseType_t xTaskResumeAll( void )
2183
2188
2184
2189
/* If uxSchedulerSuspended is zero then this function does not match a
2185
2190
* previous call to vTaskSuspendAll(). */
2186
- configASSERT ( uxSchedulerSuspended );
2191
+ configASSERT ( taskIS_SCHEDULER_SUSPENDED () );
2187
2192
2188
2193
/* It is possible that an ISR caused a task to be removed from an event
2189
2194
* list while the scheduler was suspended. If this was the case then the
@@ -2194,7 +2199,7 @@ BaseType_t xTaskResumeAll( void )
2194
2199
{
2195
2200
-- uxSchedulerSuspended ;
2196
2201
2197
- if ( uxSchedulerSuspended == ( UBaseType_t ) pdFALSE )
2202
+ if ( ! taskIS_SCHEDULER_SUSPENDED () )
2198
2203
{
2199
2204
if ( uxCurrentNumberOfTasks > ( UBaseType_t ) 0U )
2200
2205
{
@@ -2642,7 +2647,7 @@ char * pcTaskGetName( TaskHandle_t xTaskToQuery ) /*lint !e971 Unqualified char
2642
2647
/* Arrange for xTickCount to reach xNextTaskUnblockTime in
2643
2648
* xTaskIncrementTick() when the scheduler resumes. This ensures
2644
2649
* that any delayed tasks are resumed at the correct time. */
2645
- configASSERT ( uxSchedulerSuspended );
2650
+ configASSERT ( taskIS_SCHEDULER_SUSPENDED () );
2646
2651
configASSERT ( xTicksToJump != ( TickType_t ) 0 );
2647
2652
2648
2653
/* Prevent the tick interrupt modifying xPendedTicks simultaneously. */
@@ -2671,7 +2676,7 @@ BaseType_t xTaskCatchUpTicks( TickType_t xTicksToCatchUp )
2671
2676
2672
2677
/* Must not be called with the scheduler suspended as the implementation
2673
2678
* relies on xPendedTicks being wound down to 0 in xTaskResumeAll(). */
2674
- configASSERT ( uxSchedulerSuspended == 0 );
2679
+ configASSERT ( ! taskIS_SCHEDULER_SUSPENDED () );
2675
2680
2676
2681
/* Use xPendedTicks to mimic xTicksToCatchUp number of ticks occurring when
2677
2682
* the scheduler is suspended so the ticks are executed in xTaskResumeAll(). */
@@ -2780,7 +2785,7 @@ BaseType_t xTaskIncrementTick( void )
2780
2785
* tasks to be unblocked. */
2781
2786
traceTASK_INCREMENT_TICK ( xTickCount );
2782
2787
2783
- if ( uxSchedulerSuspended == ( UBaseType_t ) pdFALSE )
2788
+ if ( ! taskIS_SCHEDULER_SUSPENDED () )
2784
2789
{
2785
2790
/* Minor optimisation. The tick count cannot change in this
2786
2791
* block. */
@@ -3060,7 +3065,7 @@ BaseType_t xTaskIncrementTick( void )
3060
3065
3061
3066
void vTaskSwitchContext ( void )
3062
3067
{
3063
- if ( uxSchedulerSuspended != ( UBaseType_t ) pdFALSE )
3068
+ if ( taskIS_SCHEDULER_SUSPENDED () )
3064
3069
{
3065
3070
/* The scheduler is currently suspended - do not allow a context
3066
3071
* switch. */
@@ -3165,7 +3170,7 @@ void vTaskPlaceOnUnorderedEventList( List_t * pxEventList,
3165
3170
3166
3171
/* THIS FUNCTION MUST BE CALLED WITH THE SCHEDULER SUSPENDED. It is used by
3167
3172
* the event groups implementation. */
3168
- configASSERT ( uxSchedulerSuspended != 0 );
3173
+ configASSERT ( taskIS_SCHEDULER_SUSPENDED () );
3169
3174
3170
3175
/* Store the item value in the event list item. It is safe to access the
3171
3176
* event list item here as interrupts won't access the event list item of a
@@ -3240,7 +3245,7 @@ BaseType_t xTaskRemoveFromEventList( const List_t * const pxEventList )
3240
3245
configASSERT ( pxUnblockedTCB );
3241
3246
listREMOVE_ITEM ( & ( pxUnblockedTCB -> xEventListItem ) );
3242
3247
3243
- if ( uxSchedulerSuspended == ( UBaseType_t ) pdFALSE )
3248
+ if ( ! taskIS_SCHEDULER_SUSPENDED () )
3244
3249
{
3245
3250
listREMOVE_ITEM ( & ( pxUnblockedTCB -> xStateListItem ) );
3246
3251
prvAddTaskToReadyList ( pxUnblockedTCB );
@@ -3293,7 +3298,7 @@ void vTaskRemoveFromUnorderedEventList( ListItem_t * pxEventListItem,
3293
3298
3294
3299
/* THIS FUNCTION MUST BE CALLED WITH THE SCHEDULER SUSPENDED. It is used by
3295
3300
* the event flags implementation. */
3296
- configASSERT ( uxSchedulerSuspended != pdFALSE );
3301
+ configASSERT ( taskIS_SCHEDULER_SUSPENDED () );
3297
3302
3298
3303
/* Store the new item value in the event list. */
3299
3304
listSET_LIST_ITEM_VALUE ( pxEventListItem , xItemValue | taskEVENT_LIST_ITEM_VALUE_IN_USE );
@@ -4093,7 +4098,7 @@ static void prvResetNextTaskUnblockTime( void )
4093
4098
}
4094
4099
else
4095
4100
{
4096
- if ( uxSchedulerSuspended == ( UBaseType_t ) pdFALSE )
4101
+ if ( ! taskIS_SCHEDULER_SUSPENDED () )
4097
4102
{
4098
4103
xReturn = taskSCHEDULER_RUNNING ;
4099
4104
}
@@ -5113,7 +5118,7 @@ TickType_t uxTaskResetEventItemValue( void )
5113
5118
/* The task should not have been on an event list. */
5114
5119
configASSERT ( listLIST_ITEM_CONTAINER ( & ( pxTCB -> xEventListItem ) ) == NULL );
5115
5120
5116
- if ( uxSchedulerSuspended == ( UBaseType_t ) pdFALSE )
5121
+ if ( ! taskIS_SCHEDULER_SUSPENDED () )
5117
5122
{
5118
5123
listREMOVE_ITEM ( & ( pxTCB -> xStateListItem ) );
5119
5124
prvAddTaskToReadyList ( pxTCB );
@@ -5204,7 +5209,7 @@ TickType_t uxTaskResetEventItemValue( void )
5204
5209
/* The task should not have been on an event list. */
5205
5210
configASSERT ( listLIST_ITEM_CONTAINER ( & ( pxTCB -> xEventListItem ) ) == NULL );
5206
5211
5207
- if ( uxSchedulerSuspended == ( UBaseType_t ) pdFALSE )
5212
+ if ( ! taskIS_SCHEDULER_SUSPENDED () )
5208
5213
{
5209
5214
listREMOVE_ITEM ( & ( pxTCB -> xStateListItem ) );
5210
5215
prvAddTaskToReadyList ( pxTCB );
0 commit comments