开发者

freeRTOS and parallel processing

This is a simpl开发者_开发知识库e question: Does freeRTOS handla multiple threads in multiple processes as the "real" Linux system does?


FreeRTOS is not Linux, nor does it pretend to be, although it is a cross platform standard kernel in its own right as it supports 26 different cores - but it is designed for microcontrollers not microprocessors. Most of those cores don't use an MMU though so there is no concept of a process. If you like, all the tasks are 'threads' running in a single 'process'. That is why I use the terminology 'task' so as not to cause confusion. There are FreeRTOS versions that support the use of an MPU though, this allows memory partitioning and access rights like an MMU, but in a linear rather than virtual address space.


FreeRTOS uses a simple priority scheduler, documented here.

I'm not sure what you mean by handling threads like Linux does, but if every thread has the same priority, they should be allocated CPU time fairly.


No. (Free)RTOS generally don't have the same ideas of processes and threads as is used with a common GPOS like Linux. The term "task" is often used instead to avoid confusion.

That said, you might have a look at FreeRTOS coroutines, which are sort of execution-threads-inna-task in FreeRTOS.


Yes, rmmh is right that Tasks with similar priority will be allocated CPU time as well. This can be seen from the following website:

http://www.freertos.org/implementation/a00007.html

As an added point, FreeRTOS, as it's name suggests is a Real-Time Operating System. That being said, FreeRTOS can be configured to perform like a Time-Sharing System like that of Linux and vice-versa.

Hope that helped. Cheers!


Every process/thread/task has its own Stack. FreeRTOS allocates memory from the heap for that purpose. This is what FreeRTOS does when making a context switch from Task_A to Task_B: (1) Push all contents from the CPU registers to the stack of Task_A. (2) Make the CPU stack pointer refer to the stack of Task_B instead of Task_A. (3) The stack of Task_B has the CPU registers on top that represent the 'saved status' of the CPU when Task_B was put to sleep. Now is the time to restore those values to the CPU registers. (4) Continue running Task B.

This context switch normally happens very regularly in FreeRTOS. In this way the FreeRTOS operating system can ensure that all Tasks with highest priority get a share of the CPU time. Tasks with lower priorities get CPU time when the higher priority Tasks cannot run, eg. when they are waiting for a Queue, Semaphore, ..

FreeRTOS does not support multi-cores - as far as I know. FreeRTOS generally runs on tiny microcontrollers that have just one CPU core.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜