I am programming a simple full pre-emptive RTOS. It needs context switch. For saving contexts, is it enough to save all registers and CPSR? if tasks have local variables, and the complier uses memories to store them. If just saving registers, it seems not enough. What should I do?
thank you for your help!!!
The main important thing besides saving/restoring flags and processor registers is to switch stack.
Then you have to figure out if any functions used are non-reentrant, because they are using global variables or are playing with hardware.
There are a large number of gotchas with a RTOS, and you will have to decide how much cooperation that should be required by the tasks.
A good start if you want to write your own OS is to look at MicroC/OS-II: www.micrium.com/.../bookstore.html
View all questions in Keil forum