This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

Context switch: fpu regs saved?

Expert 3020 points

Hello,

are the fpu related resiters by default saved on a context switch?

E.g. can I use floting point in multiple tasks when using FreeRTOS or SAFERTOS?

How long does a context switch take (including fpu regs)?

 

Regards.

Lo

  • Lo,

    With C-code and a C-compiler, the compiler generates code to store and restore CPU and FPU registers for function calls.

    I am not an OS expert, but I would think that for an OS switching between tasks, this may need to be done using additional function calls. The time it takes to do so would depend on how many registers need to be saved/restored.

    Regards,

    Abhishek

     

  • Hello Abhishek,

    thanks for your reply!

    Do you know how long a task switch takes?

    Or do you know how many assembler instructions make up a function preamble?

     

    Regards,

    Lo

  • Lo,

    there is no generic answer to this question.

    The number of cycles needed for a task switch depends on what a task switch encompasses in your application. (e.g. whether MPU is being reconfigured for that particular task, whether floating point is being used, ...). It could be from tens of cycles to hundreds of cycles depending on the scope.

    Regards,

    Abhishek