X-Git-Url: https://codewiz.org/gitweb?a=blobdiff_plain;f=bertos%2Fkern%2Fproc.c;h=a18fc40498d52e85e198ee54e5e13a1e90e2c49e;hb=82aa9864bc5accc468d3c9ed109a8b44ef36da94;hp=623c1d3fb5d87dba4ceb91b5c35ddcd6f85749c8;hpb=d9d931610bca1df6ceb9227eacc9ff2c7f89b77a;p=bertos.git diff --git a/bertos/kern/proc.c b/bertos/kern/proc.c index 623c1d3f..a18fc404 100644 --- a/bertos/kern/proc.c +++ b/bertos/kern/proc.c @@ -62,14 +62,6 @@ #define PROC_SIZE_WORDS (ROUND_UP2(sizeof(Process), sizeof(cpu_stack_t)) / sizeof(cpu_stack_t)) -/** - * CPU dependent context switching routines. - * - * Saving and restoring the context on the stack is done by a CPU-dependent - * support routine which usually needs to be written in assembly. - */ -EXTERN_C void asm_switch_context(cpu_stack_t **new_sp, cpu_stack_t **save_sp); - /* * The scheduer tracks ready processes by enqueuing them in the * ready list. @@ -428,15 +420,6 @@ void proc_exit(void) ASSERT(0); } - -/** - * Get the pointer to the user data of the current process - */ -iptr_t proc_currentUserData(void) -{ - return current_process->user_data; -} - /** * Call the scheduler and eventually replace the current running process. */ @@ -470,22 +453,8 @@ void proc_schedule(void) MEMORY_BARRIER; IRQ_DISABLE; } - /* - * 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); /* This RET resumes the execution on the new process */ LOG_INFO("resuming %p:%s\n", current_process, proc_currentName()); }