- /*
- * Optimization: don't switch contexts when the active
- * process has not changed.
- */
- if (CurrentProcess != old_process)
- {
- cpustack_t *dummy;
-
- #if CONFIG_KERN_MONITOR
- LOG_INFO("Switch from %p(%s) to %p(%s)\n",
- old_process, old_process ? old_process->monitor.name : "NONE",
- CurrentProcess, CurrentProcess->monitor.name);
- #endif
-
- #if CONFIG_KERN_PREEMPTIVE
- /* Reset quantum for this process */
- Quantum = CONFIG_KERN_QUANTUM;
- #endif
-
- /* 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.
- * TODO: Instead of physically clearing the process at exit time, a zombie
- * list should be created.
- */
- asm_switch_context(&CurrentProcess->stack, old_process ? &old_process->stack : &dummy);
- }
-
- /* This RET resumes the execution on the new process */