[MSP/PSP] Context switching + Interrupt handling

Hi, I need to implement an OS-like system that handles context switching for tasks and interrupts. ( Both can use different stacks) 

Currently, I´m using Supervisor calls to perform the context switching between tasks and a main "scheduler task". See the image below.

My main scheduler function uses the main stack pointer, and the scheduled tasks use the process stack pointer.

The memory is protected for main stack/ process stack regions, and this layout works fine at the moment.

The problem is now i need to also take control of the stack used by the interrupts, so this layout needs to be changed.

After some tests, adding more SVC Calls to try to control the stack used by the interrupts, isnt working for me. So I´m opening this post finding for help / any ideas on how i can take control of the stack used by the interrupts. Thanks :)

More questions in this forum