From b6918ef2d8a2ab9c354cf5cf4269f58b73fc7d69 Mon Sep 17 00:00:00 2001 From: Ching-Hsin Lee Date: Wed, 21 Dec 2022 10:07:36 +0800 Subject: [PATCH 1/3] Update equal priority task preemption * vTaskResume and vTaskPrioritySet don't preempt equal priority task --- tasks.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tasks.c b/tasks.c index d4d8fb06f2..dfa2f99e44 100644 --- a/tasks.c +++ b/tasks.c @@ -1552,7 +1552,7 @@ static void prvAddNewTaskToReadyList( TCB_t * pxNewTCB ) /* The priority of a task other than the currently * running task is being raised. Is the priority being * raised above that of the running task? */ - if( uxNewPriority >= pxCurrentTCB->uxPriority ) + if( uxNewPriority > pxCurrentTCB->uxPriority ) { xYieldRequired = pdTRUE; } @@ -1845,7 +1845,7 @@ static void prvAddNewTaskToReadyList( TCB_t * pxNewTCB ) prvAddTaskToReadyList( pxTCB ); /* 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, * but will leave the lists in the correct state for the From c228d4c5c8fd529c56d3e76d337ec8fe6cd6088e Mon Sep 17 00:00:00 2001 From: Ching-Hsin Lee Date: Wed, 21 Dec 2022 18:31:15 +0800 Subject: [PATCH 2/3] Update vTaskResumeAll not to preempt task with equal priority --- tasks.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tasks.c b/tasks.c index dfa2f99e44..32681ea9a0 100644 --- a/tasks.c +++ b/tasks.c @@ -2203,9 +2203,9 @@ BaseType_t xTaskResumeAll( void ) listREMOVE_ITEM( &( pxTCB->xStateListItem ) ); prvAddTaskToReadyList( pxTCB ); - /* If the moved task has a priority higher than or equal to - * the current task then a yield must be performed. */ - if( pxTCB->uxPriority >= pxCurrentTCB->uxPriority ) + /* If the moved task has a priority higher than the current + * task then a yield must be performed. */ + if( pxTCB->uxPriority > pxCurrentTCB->uxPriority ) { xYieldPending = pdTRUE; } From e512aab511191b15103b1f87cc5fe56a35c0ad38 Mon Sep 17 00:00:00 2001 From: Ching-Hsin Lee Date: Wed, 21 Dec 2022 18:45:13 +0800 Subject: [PATCH 3/3] Fix in xTaskResumeFromISR --- tasks.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tasks.c b/tasks.c index 32681ea9a0..3a0f0470e7 100644 --- a/tasks.c +++ b/tasks.c @@ -1913,7 +1913,7 @@ static void prvAddNewTaskToReadyList( TCB_t * pxNewTCB ) { /* Ready lists can be accessed so move the task from the * suspended list to the ready list directly. */ - if( pxTCB->uxPriority >= pxCurrentTCB->uxPriority ) + if( pxTCB->uxPriority > pxCurrentTCB->uxPriority ) { xYieldRequired = pdTRUE;