MOD_DEFINE(preempt)
-/**
- * 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);
-
/* Global preemption nesting counter */
cpu_atomic_t preempt_count;
int preempt_needPreempt(void);
void preempt_preempt(void);
void preempt_switch(void);
+void preempt_wakeup(Process *proc);
void preempt_init(void);
/**
void preempt_switch(void)
{
ASSERT(proc_preemptAllowed());
- IRQ_ASSERT_ENABLED();
ATOMIC(preempt_schedule());
}
+/**
+ * Immediately wakeup a process, dispatching it to the CPU.
+ */
+void preempt_wakeup(Process *proc)
+{
+ ASSERT(proc_preemptAllowed());
+ ASSERT(current_process);
+ IRQ_ASSERT_DISABLED();
+
+ if (prio_proc(proc) >= prio_curr())
+ {
+ Process *old_process = current_process;
+
+ SCHED_ENQUEUE(current_process);
+ _proc_quantum = CONFIG_KERN_QUANTUM;
+ current_process = proc;
+ proc_switchTo(current_process, old_process);
+ }
+ else
+ SCHED_ENQUEUE_HEAD(proc);
+}
+
/**
* Voluntarily release the CPU.
*/