# task not switching

**URL:** <https://forums.freertos.org/t/task-not-switching/5834>\
**Category:** Kernel\
**Created:** [March 16, 2016, 9:57pm UTC](https://forums.freertos.org/t/task-not-switching/5834 "2016-03-16T21:57:03Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![system](https://d2v6vdsk2p900z.cloudfront.net/original/1X/7fc8fdb729c645aab5b20282bbe34e57cb407be6.jpeg) [@system](https://forums.freertos.org/u/system)\
**Post date:** [March 16, 2016, 9:57pm UTC](https://forums.freertos.org/t/task-not-switching/5834/1 "2016-03-16T21:57:03Z")

</div>

**[seek25](https://sourceforge.net/u/seek25/)** wrote on [Wednesday, March 16, 2016](https://sourceforge.net/p/freertos/discussion/382005/thread/11912274/#3294):

Hello,

I have 4 tasks all of the same priority, cortex M4. No task uses freeRTOS functions.

Once task A is executed it never gets pre-empted. It just gets executed over and over starving the other.

FreeRTOS is 7.3.0 and thre is no definition about time slice in the freertosconfig.h file.

How was that supposed to work?

Thanks.

IC

Edit:

From here: [http://www.freertos.org/FAQSched.html](http://www.freertos.org/FAQSched.html)

How are tasks of equal priority scheduled?  
Round robin - Ready state tasks that share a priority “take turns” to run.

---

<div class="post-metadata">

**Author:** ![system](https://d2v6vdsk2p900z.cloudfront.net/original/1X/7fc8fdb729c645aab5b20282bbe34e57cb407be6.jpeg) [@system](https://forums.freertos.org/u/system)\
**Post date:** [March 16, 2016, 10:03pm UTC](https://forums.freertos.org/t/task-not-switching/5834/2 "2016-03-16T22:03:22Z")

</div>

**[edwards3](https://sourceforge.net/u/edwards3/)** wrote on [Wednesday, March 16, 2016](https://sourceforge.net/p/freertos/discussion/382005/thread/11912274/#5c6e):

Sounds like the tick interrupt might not be running. Put a break point on xTaskIncrementTick in Task.c, is it hit?

---

<div class="post-metadata">

**Author:** ![system](https://d2v6vdsk2p900z.cloudfront.net/original/1X/7fc8fdb729c645aab5b20282bbe34e57cb407be6.jpeg) [@system](https://forums.freertos.org/u/system)\
**Post date:** [March 16, 2016, 10:10pm UTC](https://forums.freertos.org/t/task-not-switching/5834/3 "2016-03-16T22:10:44Z")

</div>

**[seek25](https://sourceforge.net/u/seek25/)** wrote on [Wednesday, March 16, 2016](https://sourceforge.net/p/freertos/discussion/382005/thread/11912274/#e0ab):

Just found this, since it is not defined it should switch between them.

configUSE\_TIME\_SLICING  
By default (if configUSE\_TIME\_SLICING is not defined, or if configUSE\_TIME\_SLICING is defined as 1) FreeRTOS uses prioritised preemptive scheduling with time slicing. That means the RTOS scheduler will always run the highest priority task that is in the Ready state, and will switch between tasks of equal priority on every RTOS tick interrupt. If configUSE\_TIME\_SLICING is set to 0 then the RTOS scheduler will still run the highest priority task that is in the Ready state, but will not switch between tasks of equal priority just because a tick interrupt has occurred.

---

<div class="post-metadata">

**Author:** ![system](https://d2v6vdsk2p900z.cloudfront.net/original/1X/7fc8fdb729c645aab5b20282bbe34e57cb407be6.jpeg) [@system](https://forums.freertos.org/u/system)\
**Post date:** [March 16, 2016, 10:13pm UTC](https://forums.freertos.org/t/task-not-switching/5834/4 "2016-03-16T22:13:46Z")

</div>

**[seek25](https://sourceforge.net/u/seek25/)** wrote on [Wednesday, March 16, 2016](https://sourceforge.net/p/freertos/discussion/382005/thread/11912274/#5c6e/0b0e):

There is no xTaskIncrementTick in tasks.c

However this gets called and increments

- Calculate the time to wake - this may overflow but this is  
not a problem. \*/  
xTimeToWake = xTickCount + xTicksToDelay;

---

<div class="post-metadata">

**Author:** ![system](https://d2v6vdsk2p900z.cloudfront.net/original/1X/7fc8fdb729c645aab5b20282bbe34e57cb407be6.jpeg) [@system](https://forums.freertos.org/u/system)\
**Post date:** [March 16, 2016, 10:36pm UTC](https://forums.freertos.org/t/task-not-switching/5834/5 "2016-03-16T22:36:29Z")

</div>

**[seek25](https://sourceforge.net/u/seek25/)** wrote on [Wednesday, March 16, 2016](https://sourceforge.net/p/freertos/discussion/382005/thread/11912274/#0429):

```
	uxCurrentNumberOfTasks	6	volatile unsigned long(static storage at address 0x20010efc.

```

)

6 tasks? I have 4 and adding the idle task will make 5, why 6 evaluated at signed portBASE\_TYPE xTaskResumeAll( void )

```
			while( listLIST_IS_EMPTY( ( xList * ) &xPendingReadyList ) == pdFALSE )
			{

```

uxNumberOfItems = 0

the below  
pxTCB = ( tskTCB \* ) listGET\_OWNER\_OF\_HEAD\_ENTRY( ( ( xList \* ) &xPendingReadyList ) );  
uxListRemove( &( pxTCB-\>xEventListItem ) );  
never reached

---

<div class="post-metadata">

**Author:** ![rtel](https://d3iykfbgfh8zhg.cloudfront.net/user_avatar/forums.freertos.org/rtel/32/31_2.png) [@rtel](https://forums.freertos.org/u/rtel)\
**Post date:** [March 17, 2016, 9:03am UTC](https://forums.freertos.org/t/task-not-switching/5834/6 "2016-03-17T09:03:36Z")

</div>

**[rtel](https://sourceforge.net/u/rtel/)** wrote on [Thursday, March 17, 2016](https://sourceforge.net/p/freertos/discussion/382005/thread/11912274/#8d5a):

Why are you using such an old version? I think in that version the function will be called vTaskIncrementTick() (v prefix instead of x prefix).

The additional task might be the timer service task - that will be the case if you have configUSE\_TIMERS set to 1.
