See more:
(untagged)
I have the following doubt, whenever a task switch happens due to some system call, scheduler will store the cpu registers in its(say task A's TCB)(Task control block) and restore the cpu registers for the other task(task B) which is goiong to run from it own TCB.
My doubt here is, what happens during interrupt, where the cpu registers for the interrupted task is stored. My understanding is that it is stored in Interrupt stack(IRQ stack, let's take ARM). So if the registers are stored in IRQ stack, and if the interrupt results in the scheduler to switch to new task(my assumtion is that scheduler runs in timer interrupt context(system ticker)), how the scheduler store the interrupted task cpu registers, since it is stored in the IRQ stack. Only when the interrupt handler returns, then only the cpu registers are restore from the IRQ stack and interrupted task continue to execute. But if the interrupted results in scheduling of new tasks(say timer interrupt, which results in scheduler selects a new task), how the interrupt handler returns? how the old task resumes? How the old task registers are restored? I am bit confused . can anyone please help me to understand the above scenario?