@@ -378,7 +378,7 @@ typedef struct tskTaskControlBlock /* The old naming convention is used to
378378 char pcTaskName [ configMAX_TASK_NAME_LEN ]; /**< Descriptive name given to the task when created. Facilitates debugging only. */
379379
380380 #if ( configUSE_TASK_PREEMPTION_DISABLE == 1 )
381- BaseType_t xPreemptionDisable ; /**< Used to prevent the task from being preempted. */
381+ UBaseType_t xPreemptionDisable ; /**< Used to prevent the task from being preempted. */
382382 #endif
383383
384384 #if ( ( portSTACK_GROWTH > 0 ) || ( configRECORD_STACK_HIGH_ADDRESS == 1 ) )
@@ -921,7 +921,7 @@ static void prvAddNewTaskToReadyList( TCB_t * pxNewTCB ) PRIVILEGED_FUNCTION;
921921 #endif
922922 {
923923 #if ( configUSE_TASK_PREEMPTION_DISABLE == 1 )
924- if ( pxCurrentTCBs [ xCoreID ]-> xPreemptionDisable == pdFALSE )
924+ if ( pxCurrentTCBs [ xCoreID ]-> xPreemptionDisable == 0U )
925925 #endif
926926 {
927927 xLowestPriorityToPreempt = xCurrentCoreTaskPriority ;
@@ -1227,7 +1227,7 @@ static void prvAddNewTaskToReadyList( TCB_t * pxNewTCB ) PRIVILEGED_FUNCTION;
12271227 ( xYieldPendings [ uxCore ] == pdFALSE ) )
12281228 {
12291229 #if ( configUSE_TASK_PREEMPTION_DISABLE == 1 )
1230- if ( pxCurrentTCBs [ uxCore ]-> xPreemptionDisable == pdFALSE )
1230+ if ( pxCurrentTCBs [ uxCore ]-> xPreemptionDisable == 0U )
12311231 #endif
12321232 {
12331233 xLowestPriority = xTaskPriority ;
@@ -2850,7 +2850,7 @@ static void prvInitialiseNewTask( TaskFunction_t pxTaskCode,
28502850 * there may now be another task of higher priority that
28512851 * is ready to execute. */
28522852 #if ( configUSE_TASK_PREEMPTION_DISABLE == 1 )
2853- if ( pxTCB -> xPreemptionDisable == pdFALSE )
2853+ if ( pxTCB -> xPreemptionDisable == 0U )
28542854 #endif
28552855 {
28562856 xYieldRequired = pdTRUE ;
@@ -3067,7 +3067,7 @@ static void prvInitialiseNewTask( TaskFunction_t pxTaskCode,
30673067 {
30683068 pxTCB = prvGetTCBFromHandle ( xTask );
30693069
3070- pxTCB -> xPreemptionDisable = pdTRUE ;
3070+ pxTCB -> xPreemptionDisable ++ ;
30713071 }
30723072 taskEXIT_CRITICAL ();
30733073
@@ -3089,12 +3089,13 @@ static void prvInitialiseNewTask( TaskFunction_t pxTaskCode,
30893089 taskENTER_CRITICAL ();
30903090 {
30913091 pxTCB = prvGetTCBFromHandle ( xTask );
3092+ configASSERT ( pxTCB -> xPreemptionDisable > 0U );
30923093
3093- pxTCB -> xPreemptionDisable = pdFALSE ;
3094+ pxTCB -> xPreemptionDisable -- ;
30943095
30953096 if ( xSchedulerRunning != pdFALSE )
30963097 {
3097- if ( taskTASK_IS_RUNNING ( pxTCB ) == pdTRUE )
3098+ if ( ( pxTCB -> xPreemptionDisable == 0U ) && ( taskTASK_IS_RUNNING ( pxTCB ) == pdTRUE ) )
30983099 {
30993100 xCoreID = ( BaseType_t ) pxTCB -> xTaskRunState ;
31003101 prvYieldCore ( xCoreID );
@@ -4889,7 +4890,7 @@ BaseType_t xTaskIncrementTick( void )
48894890 for ( xCoreID = 0 ; xCoreID < ( BaseType_t ) configNUMBER_OF_CORES ; xCoreID ++ )
48904891 {
48914892 #if ( configUSE_TASK_PREEMPTION_DISABLE == 1 )
4892- if ( pxCurrentTCBs [ xCoreID ]-> xPreemptionDisable == pdFALSE )
4893+ if ( pxCurrentTCBs [ xCoreID ]-> xPreemptionDisable == 0U )
48934894 #endif
48944895 {
48954896 if ( xYieldPendings [ xCoreID ] != pdFALSE )
0 commit comments