# Expecting round robin scheduling but only first task executed

**URL:** <https://forums.freertos.org/t/expecting-round-robin-scheduling-but-only-first-task-executed/23757>\
**Category:** Kernel\
**Created:** [August 20, 2025, 10:19am UTC](https://forums.freertos.org/t/expecting-round-robin-scheduling-but-only-first-task-executed/23757 "2025-08-20T10:19:41Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![Dr\_Nic](https://avatars.discourse-cdn.com/v4/letter/d/bc8723/32.png) [@Dr\_Nic](https://forums.freertos.org/u/Dr_Nic)\
**Post date:** [August 20, 2025, 10:19am UTC](https://forums.freertos.org/t/expecting-round-robin-scheduling-but-only-first-task-executed/23757/1 "2025-08-20T10:19:41Z")

</div>

STM32F411RE, CubeIDE

I have 4 tasks, all of equal priority, each with their own task profile counter,

```auto
void acquire_tsk(void *pvParameters);
void noise_tsk(void *pvParameters);
void combine_tsk(void *pvParameters);
void filter_tsk(void *pvParameters);

uint32_t task1Profiler, task3Profiler, task3Profiler, task4Profiler;

main()
{

    xTaskCreate(acquire_tsk, "get signal", 100, NULL, 1, NULL);
    xTaskCreate(noise_tsk, "get noise", 100, NULL, 1, NULL);
    xTaskCreate(combine_tsk, "combine signal", 100, NULL, 1, NULL); 
    xTaskCreate(filter_tsk, "filter signal", 100, NULL, 1, NULL);

    vTaskStartScheduler();

    while(){}

}

void acquire_tsk(void *pvParameters)
{
    while(1)
    {
        task1Profiler++;
    }
}

void noise_tsk(void *pvParameters)
{
    while(1)
    {
        task2Profiler++;
    }
}

void combine_tsk(void *pvParameters)
{
    while(1)
    {
        task3Profiler++;
    }
}

void filter_tsk(void *pvParameters)
{
    while(1)
    {
        task1Profiler++;
    }
}

```

When I open up my debugger & track the task profilers only `task1Profiler` counts up, all the others remain at `0`.  
I was expecting round robin scheduling & to see all the task profilers to count up. What am I missing here?

---

<div class="post-metadata">

**Author:** ![hs2](https://avatars.discourse-cdn.com/v4/letter/h/a4c791/32.png) [@hs2](https://forums.freertos.org/u/hs2)\
**Post date:** [August 20, 2025, 10:38am UTC](https://forums.freertos.org/t/expecting-round-robin-scheduling-but-only-first-task-executed/23757/2 "2025-08-20T10:38:05Z")

</div>

Did you configure your FreeRTOS app accordingly ?

> **[FreeRTOS scheduling (single-core, AMP and SMP) - FreeRTOS™](https://m.freertos.org/Documentation/02-Kernel/02-Kernel-features/01-Tasks-and-co-routines/04-Task-scheduling)**
>
> FreeRTOS scheduling algorithm for single-core, asymmetric multicore (AMP), and symmetric multicore (SMP) RTOS configurations

---

<div class="post-metadata">

**Author:** ![Dr\_Nic](https://avatars.discourse-cdn.com/v4/letter/d/bc8723/32.png) [@Dr\_Nic](https://forums.freertos.org/u/Dr_Nic)\
**Post date:** [August 20, 2025, 11:04am UTC](https://forums.freertos.org/t/expecting-round-robin-scheduling-but-only-first-task-executed/23757/3 "2025-08-20T11:04:39Z")

</div>

I am using the default config which according to the docs,

> By default, FreeRTOS uses a fixed-priority preemptive scheduling policy, with round-robin time-slicing of equal priority tasks

---

<div class="post-metadata">

**Author:** ![hs2](https://avatars.discourse-cdn.com/v4/letter/h/a4c791/32.png) [@hs2](https://forums.freertos.org/u/hs2)\
**Post date:** [August 20, 2025, 11:14am UTC](https://forums.freertos.org/t/expecting-round-robin-scheduling-but-only-first-task-executed/23757/4 "2025-08-20T11:14:13Z")

</div>

Seems right then.  
So … maybe the SysTick isn’t running or not setup correctly ?  
You could put a breakpoint @ `xTaskIncrementTick` to see if it’s hit periodically or halt the target and check that the (global) `xTickCount` variable is incremented.

---

<div class="post-metadata">

**Author:** ![Dr\_Nic](https://avatars.discourse-cdn.com/v4/letter/d/bc8723/32.png) [@Dr\_Nic](https://forums.freertos.org/u/Dr_Nic)\
**Post date:** [August 20, 2025, 11:33am UTC](https://forums.freertos.org/t/expecting-round-robin-scheduling-but-only-first-task-executed/23757/5 "2025-08-20T11:33:25Z")

</div>

Put a break point @`TaskIncrementTick` it is never hit  
`xTickCount` variable is never incremented.

---

<div class="post-metadata">

**Author:** ![Dr\_Nic](https://avatars.discourse-cdn.com/v4/letter/d/bc8723/32.png) [@Dr\_Nic](https://forums.freertos.org/u/Dr_Nic)\
**Post date:** [August 20, 2025, 11:56am UTC](https://forums.freertos.org/t/expecting-round-robin-scheduling-but-only-first-task-executed/23757/6 "2025-08-20T11:56:49Z")

</div>

Although HAL timebase functions are declared as weak, do you think this might a problem with HAL using SysTick as well as RTOS using it?

---

<div class="post-metadata">

**Author:** ![Dr\_Nic](https://avatars.discourse-cdn.com/v4/letter/d/bc8723/32.png) [@Dr\_Nic](https://forums.freertos.org/u/Dr_Nic)\
**Post date:** [August 20, 2025, 12:17pm UTC](https://forums.freertos.org/t/expecting-round-robin-scheduling-but-only-first-task-executed/23757/7 "2025-08-20T12:17:13Z")

</div>

Yes it was the HAL messing with FreeRTOS’s handling of SysTick, thanks for the pointer.

Changed HAL’s clock by changing SYS clock to TIM1 & all is working as expected.

---

<div class="post-metadata">

**Author:** ![aggarg](https://d3iykfbgfh8zhg.cloudfront.net/user_avatar/forums.freertos.org/aggarg/32/4245_2.png) [@aggarg](https://forums.freertos.org/u/aggarg)\
**Post date:** [August 20, 2025, 2:56pm UTC](https://forums.freertos.org/t/expecting-round-robin-scheduling-but-only-first-task-executed/23757/8 "2025-08-20T14:56:16Z")

</div>

> [@Dr\_Nic](#):
>
> ```auto
> void acquire_tsk(void *pvParameters)
> {
> task1Profiler++;
> }
> 
> void noise_tsk(void *pvParameters)
> {
> task2Profiler++;
> }
> 
> void combine_tsk(void *pvParameters)
> {
> task3Profiler++;
> }
> 
> void filter_tsk(void *pvParameters)
> {
> task1Profiler++;
> }
> 
> ```

FreeRTOS tasks are not supposed to exit. You need to either make them infinite loop or call vTaskDelete:

```c
void acquire_tsk(void *pvParameters)
{
    for( ;; )
    {
        task1Profiler++;
        vTaskDelay( pdMS_TO_TICKS( 1000 ) );
    }
}

OR 

void acquire_tsk(void *pvParameters)
{
    task1Profiler++;
    vTaskDelete( NULL );
}

```

---

<div class="post-metadata">

**Author:** ![Dr\_Nic](https://avatars.discourse-cdn.com/v4/letter/d/bc8723/32.png) [@Dr\_Nic](https://forums.freertos.org/u/Dr_Nic)\
**Post date:** [August 20, 2025, 3:03pm UTC](https://forums.freertos.org/t/expecting-round-robin-scheduling-but-only-first-task-executed/23757/9 "2025-08-20T15:03:24Z")

</div>

OOps my bad they are all in a `while(1){}` loop. In my haste I forgot to include that, will edit the OP accordingly.
