roughly how many instructions does it take to do a complete task context switch? I know it depends on the micro etc. But roughly, are we talking about 10-15 or 50-100?
If only 10 or so, it is not that relevant to my question. But if longer, then what happens if an ISR (which then notifies a higher priority task) occurs in the middle or at the beginning of a context switch?
I assume the ISR executes immediately interrupting the previously running context switch. But does freeRTOS then goes back to complete the first context switch and then does the second context switch to run the higher-priority task?
Or does the higher priority task run immediately after the ISR leaving the previous context switcing “dangling” half way through until freeRTOS goes back to it later when exiting the higher priority task?
I am asking because if the context switch takes 50-100 instructions then the two scenarios described above could cause quite a different in latency in executing the high-priority task.