proc_p.h

Go to the documentation of this file.
00001 
00040 #ifndef KERN_PROC_P_H
00041 #define KERN_PROC_P_H
00042 
00043 #include "cfg/cfg_proc.h"
00044 #include "cfg/cfg_monitor.h"
00045 
00046 #include <cfg/compiler.h>
00047 
00048 #include <cpu/types.h>        /* for cpu_stack_t */
00049 #include <cpu/irq.h>          // IRQ_ASSERT_DISABLED()
00050 
00051 #if CONFIG_KERN_PREEMPT
00052     #include <ucontext.h> // XXX
00053 #endif
00054 
00055 #include <kern/proc.h>   // struct Process
00056 
00057 
00062 #define PF_FREESTACK  BV(0)  
00063 /*\}*/
00064 
00065 
00067 extern REGISTER Process *CurrentProcess;
00068 
00074 extern REGISTER List     ProcReadyList;
00075 
00076 #if CONFIG_KERN_PRI
00077     #define SCHED_ENQUEUE_INTERNAL(proc) LIST_ENQUEUE(&ProcReadyList, &(proc)->link)
00078 #else
00079     #define SCHED_ENQUEUE_INTERNAL(proc) ADDTAIL(&ProcReadyList, &(proc)->link)
00080 #endif
00081 
00091 #define SCHED_ENQUEUE(proc)  do { \
00092         IRQ_ASSERT_DISABLED(); \
00093         LIST_ASSERT_VALID(&ProcReadyList); \
00094         SCHED_ENQUEUE_INTERNAL(proc); \
00095     } while (0)
00096 
00097 #if CONFIG_KERN_PRI
00098 
00108 INLINE void sched_reenqueue(struct Process *proc)
00109 {
00110     IRQ_ASSERT_DISABLED();
00111     LIST_ASSERT_VALID(&ProcReadyList);
00112     Node *n;
00113     PriNode *pos = NULL;
00114     FOREACH_NODE(n, &ProcReadyList)
00115     {
00116         if (n == &proc->link.link)
00117         {
00118             pos = (PriNode *)n;
00119             break;
00120         }
00121     }
00122 
00123     // only remove and enqueue again if process is already in the ready list
00124     // otherwise leave it alone
00125     if (pos)
00126     {
00127         REMOVE(&proc->link.link);
00128         LIST_ENQUEUE(&ProcReadyList, &proc->link);
00129     }
00130 }
00131 #endif //CONFIG_KERN_PRI
00132 
00134 void proc_switch(void);
00135 
00136 #if CONFIG_KERN_PREEMPT
00137 void proc_entry(void (*user_entry)(void));
00138 void preempt_init(void);
00139 #endif
00140 
00141 #if CONFIG_KERN_MONITOR
00142 
00143     void monitor_init(void);
00144 
00146     void monitor_add(Process *proc, const char *name);
00147 
00149     void monitor_remove(Process *proc);
00150 
00152     void monitor_rename(Process *proc, const char *name);
00153 #endif /* CONFIG_KERN_MONITOR */
00154 
00155 #endif /* KERN_PROC_P_H */