coop.c
Go to the documentation of this file.00001 00040 #include "proc_p.h" 00041 #include "proc.h" 00042 00043 // Log settings for cfg/log.h. 00044 #define LOG_LEVEL KERN_LOG_LEVEL 00045 #define LOG_FORMAT KERN_LOG_FORMAT 00046 #include <cfg/log.h> 00047 00048 #include <cpu/irq.h> 00049 #include <cpu/types.h> 00050 #include <cpu/attr.h> 00051 #include <cpu/frame.h> 00052 00058 void coop_yield(void); 00059 void coop_switch(void); 00060 void coop_wakeup(Process *proc); 00061 00070 void coop_switch(void) 00071 { 00072 ATOMIC(proc_schedule()); 00073 } 00074 00078 void coop_wakeup(Process *proc) 00079 { 00080 ASSERT(proc_preemptAllowed()); 00081 ASSERT(current_process); 00082 IRQ_ASSERT_DISABLED(); 00083 00084 if (prio_proc(proc) >= prio_curr()) 00085 { 00086 Process *old_process = current_process; 00087 00088 SCHED_ENQUEUE(current_process); 00089 current_process = proc; 00090 proc_switchTo(current_process, old_process); 00091 } 00092 else 00093 SCHED_ENQUEUE_HEAD(proc); 00094 } 00095 00099 void coop_yield(void) 00100 { 00101 ATOMIC(SCHED_ENQUEUE(current_process)); 00102 coop_switch(); 00103 }
