cancel
Showing results for 
Search instead for 
Did you mean: 

Threads in FreeRTOS vs Threads we are met with in Intel processors, Is that the same?

Alden Kuljici
Associate III

In my last projects, i've been dealing with FreeRTOS programming...there i had a chance to create multiple threads and test them.

Then i recall when checking the performance of our pcs we see something like 4 cores, 8 threads, etc.

Does the term thread mean the same in both examples: in FreeRTOS where we create by will and the ones we see in Intel processors?

Thanks

1 ACCEPTED SOLUTION

Accepted Solutions
KnarfB
Principal III

FreeRTOS threads are quite similar to threads in Windows or Linux or other OSes. It is a software concept of multiple executions paths (thread functions) running in a shared memory space, but with one stack per thread. I.e. local variables are defined per-thread.

If you look at the hardware, a 4 core 8 thread CPU has hardware support for running up to 8 threads in parallel, whereas on a single core MCU the threads are executed on the same core and the OS scheduler switches between threads by saving the state of one thread and restoring the state of the next thread due in short time slices (pre-emptive multitasking). On the above mutli-core CPUs, some threads can be executed truely in parallel thereby saving most of the scheduling overhead.

There are subtile differences like real-time requirements which are absent on most desktop OSes, hanlding priorities in detail etc..

On a desktop OS are more concepts of parallel execution present like processes and fibres which are not present in FreeRTOS.

hth

KnarfB

View solution in original post

4 REPLIES 4
KnarfB
Principal III

FreeRTOS threads are quite similar to threads in Windows or Linux or other OSes. It is a software concept of multiple executions paths (thread functions) running in a shared memory space, but with one stack per thread. I.e. local variables are defined per-thread.

If you look at the hardware, a 4 core 8 thread CPU has hardware support for running up to 8 threads in parallel, whereas on a single core MCU the threads are executed on the same core and the OS scheduler switches between threads by saving the state of one thread and restoring the state of the next thread due in short time slices (pre-emptive multitasking). On the above mutli-core CPUs, some threads can be executed truely in parallel thereby saving most of the scheduling overhead.

There are subtile differences like real-time requirements which are absent on most desktop OSes, hanlding priorities in detail etc..

On a desktop OS are more concepts of parallel execution present like processes and fibres which are not present in FreeRTOS.

hth

KnarfB

TDK
Guru

A significant difference is that the MCU has a single core and can only run one thread at a time, whereas most desktop processors have multiple cores and can run up to 2 threads per core (hyperthreading).

Therefore, on an STM32 MCU, designing a multi-threaded application doesn't give you any performance bonus compared to a single thread doing all the tasks, since only one thing is running at a time.

If you feel a post has answered your question, please click "Accept as Solution".
Pavel A.
Evangelist III

In Intel's slang, a "thread" is a logical CPU. So for example 4 cores 8 threads means that one so called "core" has two hyper-threaded logical processors.

Such chip can run 8 software threads simultaneously.

Whether any software thread can migrate among logical processors depends on its affinity settings.

In FreeRTOS a thread means just a software thread.

Alden Kuljici
Associate III

Thank you all a lot!

Your explanationa made it much clearer.