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_signal.h"
00045 #include "cfg/cfg_monitor.h"
00046 
00047 #include <cfg/compiler.h>
00048 
00049 #include <cpu/types.h>        /* for cpu_stack_t */
00050 
00051 #include <struct/list.h>
00052 
00053 #if CONFIG_KERN_PREEMPT
00054     #include <ucontext.h> // XXX
00055 #endif
00056 
00057 typedef struct Process
00058 {
00059 #if CONFIG_KERN_PRI
00060     PriNode      link;        
00061 #else
00062     Node         link;        
00063 #endif
00064     cpu_stack_t  *stack;       
00065     iptr_t       user_data;   
00067 #if CONFIG_KERN_SIGNALS
00068     sigmask_t    sig_wait;    
00069     sigmask_t    sig_recv;    
00070 #endif
00071 
00072 #if CONFIG_KERN_HEAP
00073     uint16_t     flags;       
00074 #endif
00075 
00076 #if CONFIG_KERN_HEAP | CONFIG_KERN_MONITOR | (ARCH & ARCH_EMUL)
00077     cpu_stack_t  *stack_base;  
00078     size_t       stack_size;  
00079 #endif
00080 
00081 #if CONFIG_KERN_PREEMPT
00082     ucontext_t   context;
00083 #endif
00084 
00085 #if CONFIG_KERN_MONITOR
00086     struct ProcMonitor
00087     {
00088         Node        link;
00089         const char *name;
00090     } monitor;
00091 #endif
00092 
00093 } Process;
00094 
00095 
00100 #define PF_FREESTACK  BV(0)  
00101 /*\}*/
00102 
00103 
00105 extern REGISTER Process *CurrentProcess;
00106 
00112 extern REGISTER List     ProcReadyList;
00113 
00114 #if CONFIG_KERN_PRI
00115     #define SCHED_ENQUEUE_INTERNAL(proc) LIST_ENQUEUE(&ProcReadyList, &(proc)->link)
00116 #else
00117     #define SCHED_ENQUEUE_INTERNAL(proc) ADDTAIL(&ProcReadyList, &(proc)->link)
00118 #endif
00119 
00129 #define SCHED_ENQUEUE(proc)  do { \
00130         IRQ_ASSERT_DISABLED(); \
00131         LIST_ASSERT_VALID(&ProcReadyList); \
00132         SCHED_ENQUEUE_INTERNAL(proc); \
00133     } while (0)
00134 
00135 
00137 void proc_switch(void);
00138 
00139 #if CONFIG_KERN_PREEMPT
00140 void proc_entry(void (*user_entry)(void));
00141 void preempt_init(void);
00142 #endif
00143 
00144 #if CONFIG_KERN_MONITOR
00145 
00146     void monitor_init(void);
00147 
00149     void monitor_add(Process *proc, const char *name);
00150 
00152     void monitor_remove(Process *proc);
00153 
00155     void monitor_rename(Process *proc, const char *name);
00156 #endif /* CONFIG_KERN_MONITOR */
00157 
00158 #endif /* KERN_PROC_P_H */