Should idle thread be invoked before main?


artur.lipowski@...
 

Hi,

I found that idle thread is executed before main thread and I am not sure if it is by design or it is by coincidence or maybe it is purely my setup problem.

What I did is adding 2 lines to idle thread entry point at the beginning of while(true) loop:
...
    extern volatile uint32_t idle_entry;
    idle_entry++;
...

And as first lines of main I have following code:
    if (idle_entry > 0) {
        printk("idle_entry: %u", idle_entry);
    }
 
The output is:
idle_entry: 2

Using different PM options and disabling PM does not change output.

Is it expected behavior?
For me it seems to be somehow nonintuitive if lowest priority thread gains control before threads with higher priorities.


BTW> Zephyr code is as it is for today (449c37808a68824faa93b77fe24f39f05e9a9939), SDK 0.13.1 and target is STM32WB55.

Regards,
Artur

Join users@lists.zephyrproject.org to automatically receive all group messages.