- /*
- * Optimization: don't switch contexts when the active process has not
- * changed.
- */
- if (LIKELY(current_process != old_process)) {
- cpu_stack_t *dummy;
-
- /*
- * Save context of old process and switch to new process. If
- * there is no old process, we save the old stack pointer into
- * a dummy variable that we ignore. In fact, this happens only
- * when the old process has just exited.
- */
- asm_switch_context(¤t_process->stack,
- old_process ? &old_process->stack : &dummy);
- }
+ if (CONTEXT_SWITCH_FROM_ISR())
+ proc_switchTo(current_process, old_process);