Update equal priority task preemption (#603)

* vTaskResume and vTaskPrioritySet don't preempt equal priority task

* Update vTaskResumeAll not to preempt task with equal priority

* Fix in xTaskResumeFromISR
This commit is contained in:
chinglee-iot 2023-01-06 10:42:13 +08:00 committed by GitHub
parent 6d65558ba0
commit bb6071e1df
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

12
tasks.c
View file

@ -1552,7 +1552,7 @@ static void prvAddNewTaskToReadyList( TCB_t * pxNewTCB )
/* The priority of a task other than the currently /* The priority of a task other than the currently
* running task is being raised. Is the priority being * running task is being raised. Is the priority being
* raised above that of the running task? */ * raised above that of the running task? */
if( uxNewPriority >= pxCurrentTCB->uxPriority ) if( uxNewPriority > pxCurrentTCB->uxPriority )
{ {
xYieldRequired = pdTRUE; xYieldRequired = pdTRUE;
} }
@ -1845,7 +1845,7 @@ static void prvAddNewTaskToReadyList( TCB_t * pxNewTCB )
prvAddTaskToReadyList( pxTCB ); prvAddTaskToReadyList( pxTCB );
/* A higher priority task may have just been resumed. */ /* A higher priority task may have just been resumed. */
if( pxTCB->uxPriority >= pxCurrentTCB->uxPriority ) if( pxTCB->uxPriority > pxCurrentTCB->uxPriority )
{ {
/* This yield may not cause the task just resumed to run, /* This yield may not cause the task just resumed to run,
* but will leave the lists in the correct state for the * but will leave the lists in the correct state for the
@ -1913,7 +1913,7 @@ static void prvAddNewTaskToReadyList( TCB_t * pxNewTCB )
{ {
/* Ready lists can be accessed so move the task from the /* Ready lists can be accessed so move the task from the
* suspended list to the ready list directly. */ * suspended list to the ready list directly. */
if( pxTCB->uxPriority >= pxCurrentTCB->uxPriority ) if( pxTCB->uxPriority > pxCurrentTCB->uxPriority )
{ {
xYieldRequired = pdTRUE; xYieldRequired = pdTRUE;
@ -2203,9 +2203,9 @@ BaseType_t xTaskResumeAll( void )
listREMOVE_ITEM( &( pxTCB->xStateListItem ) ); listREMOVE_ITEM( &( pxTCB->xStateListItem ) );
prvAddTaskToReadyList( pxTCB ); prvAddTaskToReadyList( pxTCB );
/* If the moved task has a priority higher than or equal to /* If the moved task has a priority higher than the current
* the current task then a yield must be performed. */ * task then a yield must be performed. */
if( pxTCB->uxPriority >= pxCurrentTCB->uxPriority ) if( pxTCB->uxPriority > pxCurrentTCB->uxPriority )
{ {
xYieldPending = pdTRUE; xYieldPending = pdTRUE;
} }