# Task context switch happend between two same priority tasks with configUSE\_TIME\_SLICING=0

**URL:** <https://forums.freertos.org/t/task-context-switch-happend-between-two-same-priority-tasks-with-configuse-time-slicing-0/14478>\
**Category:** Kernel\
**Created:** [February 15, 2022, 3:52am UTC](https://forums.freertos.org/t/task-context-switch-happend-between-two-same-priority-tasks-with-configuse-time-slicing-0/14478 "2022-02-15T03:52:49Z")\
**Posts on this page:** 1\
**Showing post:** 9

<div class="post-metadata">

**Author:** ![qwertyuiop](https://avatars.discourse-cdn.com/v4/letter/q/db5fbb/32.png) [@qwertyuiop](https://forums.freertos.org/u/qwertyuiop)\
**Post date:** [February 16, 2022, 3:43am UTC](https://forums.freertos.org/t/task-context-switch-happend-between-two-same-priority-tasks-with-configuse-time-slicing-0/14478/9 "2022-02-16T03:43:43Z")

</div>

@richard-damon @rtel  
Hi All,

Below explaination copied from  
With configUSE\_TIME\_SLICING set to 0 a context switch should not occur  
on a tick interrupt, but only when a higher priority task enters the  
Ready state, or when an interrupt other than the tick interrupt requests  
a context switch.

> [@Tasks w/ same Priority Interrupt even with time slice off](https://forums.freertos.org/t/tasks-w-same-priority-interrupt-even-with-time-slice-off/3282/3):
>
> [dnewby](https://sourceforge.net/u/dnewby/) wrote on [Wednesday, December 02, 2015](https://sourceforge.net/p/freertos/discussion/382005/thread/9336ef42/#5fb9/f3db): My sys tick interrupt occurs and it switches to task1 afterwards. Is there a configuration to set so that the same task runs before and after a context switch even if there are other tasks with the same priority? Also, if I change my tasks to print ‘1’ or ‘2’ respectively in the task loop, it prints '1’s until the systick interrupt, then '2’s, as you have said would happen. However, it never switches back to '1’s on the next systick interrupt. Why …

It mentioned a **higher** priority task enter the ready state, then a context switch will happen. It make sense to me. But now in my test if a equal priority task enter the ready state, the context switch happend as well. That’s the point I can‘t accept.

I think the related code is “if( pxTCB-\>uxPriority \>= pxCurrentTCB-\>uxPriority )” in tasks.c file casue the context switch between two same priority task. Can I change the “\>=” to “\>”, what will the issues happened, potential risk if I do this change?

Thanks.  
Best Regards.

---

_[View the full topic](https://forums.freertos.org/t/task-context-switch-happend-between-two-same-priority-tasks-with-configuse-time-slicing-0/14478)._
