For our RTOS, I have decided to use SVC for syscall (since you can pass an 8-bit argument to specify which system call), PendSV for context switching, and the SysTick timer for the tick interrupt. These exceptions run at lowest priority urgency (15 for the -M4/-M7) so peripheral interrupts have higher priorities.
All are working great, we have 2 sets of message passing (synchronous QNX style and Mailboxes) API, Semaphores, MUTEX etc. Then I integrated it with lwIP, and after getting everything to build, the test started to crash fairly early on.
The problem is that the ethernet driver uses a callback function to signal a semaphore to alert the main TCP/IP thread that data is available. As the callback is made in an interrupt handler, the SVC call does... I have no idea what. (Since I was just swapping code out, I did not realize that the semaphore signaling is happening inside an ISR handler.)
(Solution is simple: provide some API that are safe to call from an ISR. FreeRTOS has similar set of API even though it does not use SVC for syscalls)
The question is, from the CPU/MCU point of view, what exactly happens when an ISR handler calls the SVC instruction with lower urgency? It cannot take the SVC exception immediately, but does it somehow pend the SVC execution, which kind of makes no sense either, or does it treat it as a no-op?
Anyone knows?