Re: [distortos-development] Newbie getting started
object-oriented C++ RTOS for microcontrollers
Brought to you by:
distortec
|
From: Kamil S. <dis...@di...> - 2018-02-03 21:17:05
|
On Sat, 2018-02-03 at 15:09 -0500, Trampas Stern wrote: > I was looking through some FreeRTOS documentation on how the Cortex M > processors work with RTOSs. I personally like the ground up approach > to learning new things... I was hoping that maybe you had a blog > going through the ground up on DISTOREC? > > I will go through and see if I can figure it out either way... Generally all RTOSes work (more or less) the same. The "mechanics" is mostly identical - PendSV is used for context switching and SysTick is used as periodic timer. If anything wants to force a context switch, it has to trigger PendSV interrupt. There may be some minor differences in this particular aspect, but the general concept of context switching is pretty much identical in any RTOS. It is not even very specific to ARM Cortex-M - obviously the tiny details (assembly instructions, interrupts used, registers that need to be saved, ...) will be different, but the approach (push registers to stack, save stack pointer of thread "A", load stack pointer of thread "B", pop registers from stack) is still identical. Unless you are interested in something other than context switching? This definitely is one of a very few architecture-specific things in an RTOS. Huge majority of code is architecture-agnostic - it can be seen by how little code is in the architecture folder (at least I think there's "little" (; ). https://github.com/DISTORTEC/distortos/tree/master/source/architecture/ARM/ARMv6-M-ARMv7-M If you ignore the stuff which is required for implementation of POSIX signals (which would be SVC interrupt, supervisorCall and requestFunctionExecution), all that is left is: - code for context switching (PendSV), - code to request context switching, - code related to periodic tick interrupt (SysTick and startScheduling), - code to initialize thread's stack, - various low-level initializers (including reset handler), - code to enable, disable and restore interrupt masking (used for critical sections), - function which tells whether you are in interrupt context (used in various integrity checks). Please let me know if you have some specific questions, as the topic you mention would nicely fill a small book, so the scope is a bit too large for an e-mail (; Regards, KSz |