This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Saving context before a switch

Hello,
I am working with an xc167. Currently I use a round-robin schedular, but I want to write my own preemptive schedular. I have browsed through the user manual, but it is still not 100% clear to me exactly which registers should be saved per task. I was thinking of the general purpose registers, SP, IP, PSW...
Can anybody advise me as to the full list?
Thanks in advance.

Parents
  • Since you don't know what is happing in the code for each task you basically need to save everything.

    So, in addition to the registers what you already mentioned you need the DPP's, MDL, MDH and MDC registers. You would have to use the global register bank for each of your task contexts. If you are also using the MAC registers then you would have to save them also.

    Please be careful with R0 as this is the pointer to the user stack.

    To get an idea you could put a call into one of your interrupt routines and see what the compiler is saving.

Reply
  • Since you don't know what is happing in the code for each task you basically need to save everything.

    So, in addition to the registers what you already mentioned you need the DPP's, MDL, MDH and MDC registers. You would have to use the global register bank for each of your task contexts. If you are also using the MAC registers then you would have to save them also.

    Please be careful with R0 as this is the pointer to the user stack.

    To get an idea you could put a call into one of your interrupt routines and see what the compiler is saving.

Children
No data