tock
tock copied to clipboard
RFC: Multicore Support
Moved from #2539. Some discussion there.
Several MCUs provide multiple processing core within the ARM Cortex. One example is the Raspberry Pi Pico that is a dual core M0+. Another example is Arduino Portenta H7 (STM32 with two cores, an M4 and an M7).
I am not sure how this should be handled by Tock so I am opening this PR to get some feedback.
I think there might be several approaches to this, with pros and cons for each of them.
SMP
This seems to be the most intuitive approach. The kernel runs and schedules all the processes on any of the available cores.
Pros
- easy to understand and use for use space developer perspective, no changes are needed
- allows faster processing no matter what actions the apps perform
Cons
- breaks the idea that drivers run uninterrupted on a single thread, requires drivers rewrite
- make the kernel scheduler more complex as it needs to take into account processes that might have already been scheduled by the kernel running on another core
Dedicated core for a specific process
The idea is to use the additional cores for one single user space process. This process:
- should only perform processing task
- should never be preempted
- may only use system calls to a specific set of drivers that are never used by the main core kernel
Pros
- allows real time processing in user space
- rather simple implementation in the kernel, no scheduling required
Cons
- user space programming is different, due to limited API that is usable
- might not use all the processing power available, as the core is used only by one single process
Separated kernels
The idea is to run a separate kernel on each core. Each kernel:
- has its own memory space
- loads a different subset of applications
- loads a different subset of drivers
Pros
- easy to implement, requires minimal kernel changes
- should work with different core types (Arduino Protenta H7 has an M4 and an M7)
Cons
- might waste memory resources
- requires some driver changes to be able to share peripherals among the kernels