Reputation: 801
If i have two tasks TASK_A and TASK_B.
Stack size of TASK_A = 300
Stack size of TASK_B = 600
Does context switching time for TASK_A and TASK_B have any dependency on their respective stack size.
Upvotes: 1
Views: 250
Reputation: 7057
No, task stack size does not effect context switching time. Each task has its own stack in an separate range of memory. During a context switch, the processor's stack pointer register is changed to point to a different task's stack. The stacks are not copied or moved during a context switch so the stack size does not effect context switching time.
Upvotes: 6
Reputation:
Context switching is the process in which the system switches from one task to another in a multitasking environment. It is a general term. There can be many types of switches like register, thread, stack etc. If you are particularly referring to stack frame switches, then it involves push or pop operations and some register restore operations, which are constant time operations, atleast in theory. It doesn't depend on the size of the stack itself.
Upvotes: 1