Skip to content

Commit f209c6e

Browse files
aggargchinglee-iot
authored andcommitted
Fix context switch when time slicing is off (FreeRTOS#568)
* Fix context switch when time slicing is off When time slicing is off, context switch should only happen when a task with priority higher than the currently executing one is unblocked. Earlier the code was invoking a context switch even when a task with priority equal the currently executing task was unblocked. This commit fixes the code to only do a context switch when a higher priority task is unblocked. Signed-off-by: Gaurav Aggarwal <[email protected]>
1 parent 1ad8899 commit f209c6e

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

tasks.c

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4090,10 +4090,14 @@ BaseType_t xTaskIncrementTick( void )
40904090
#if ( configNUM_CORES == 1 )
40914091
{
40924092
/* Preemption is on, but a context switch should
4093-
* only be performed if the unblocked task has a
4094-
* priority that is equal to or higher than the
4095-
* currently executing task. */
4096-
if( pxTCB->uxPriority >= pxCurrentTCB->uxPriority )
4093+
* only be performed if the unblocked task's
4094+
* priority is higher than the currently executing
4095+
* task.
4096+
* The case of equal priority tasks sharing
4097+
* processing time (which happens when both
4098+
* preemption and time slicing are on) is
4099+
* handled below.*/
4100+
if( pxTCB->uxPriority > pxCurrentTCB->uxPriority )
40974101
{
40984102
xSwitchRequired = pdTRUE;
40994103
}

0 commit comments

Comments
 (0)