context switch

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!!!

Parents
  • 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.

Reply
  • 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.

Children
More questions in this forum