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>
00049 #include <cpu/irq.h>
00050
00051 #include <kern/proc.h>
00052
00053 #ifndef asm_switch_context
00054
00060 EXTERN_C void asm_switch_context(cpu_stack_t **new_sp, cpu_stack_t **save_sp);
00061 #endif
00062
00067 #define PF_FREESTACK BV(0)
00068
00069
00070
00072 extern REGISTER Process *current_process;
00073
00079 extern REGISTER List proc_ready_list;
00080
00081 #if CONFIG_KERN_PRI
00082 #define prio_next() (LIST_EMPTY(&proc_ready_list) ? INT_MIN : \
00083 ((PriNode *)LIST_HEAD(&proc_ready_list))->pri)
00084 #define prio_proc(proc) (proc->link.pri)
00085 #define prio_curr() prio_proc(current_process)
00086
00087 #define SCHED_ENQUEUE_INTERNAL(proc) \
00088 LIST_ENQUEUE(&proc_ready_list, &(proc)->link)
00089 #define SCHED_ENQUEUE_HEAD_INTERNAL(proc) \
00090 LIST_ENQUEUE_HEAD(&proc_ready_list, &(proc)->link)
00091 #else
00092 #define prio_next() 0
00093 #define prio_proc(proc) 0
00094 #define prio_curr() 0
00095
00096 #define SCHED_ENQUEUE_INTERNAL(proc) ADDTAIL(&proc_ready_list, &(proc)->link)
00097 #define SCHED_ENQUEUE_HEAD_INTERNAL(proc) ADDHEAD(&proc_ready_list, &(proc)->link)
00098 #endif
00099
00109 #define SCHED_ENQUEUE(proc) do { \
00110 IRQ_ASSERT_DISABLED(); \
00111 LIST_ASSERT_VALID(&proc_ready_list); \
00112 SCHED_ENQUEUE_INTERNAL(proc); \
00113 } while (0)
00114
00115 #define SCHED_ENQUEUE_HEAD(proc) do { \
00116 IRQ_ASSERT_DISABLED(); \
00117 LIST_ASSERT_VALID(&proc_ready_list); \
00118 SCHED_ENQUEUE_HEAD_INTERNAL(proc); \
00119 } while (0)
00120
00121
00122 #if CONFIG_KERN_PRI
00123
00133 INLINE void sched_reenqueue(struct Process *proc)
00134 {
00135 IRQ_ASSERT_DISABLED();
00136 LIST_ASSERT_VALID(&proc_ready_list);
00137 Node *n;
00138 PriNode *pos = NULL;
00139 FOREACH_NODE(n, &proc_ready_list)
00140 {
00141 if (n == &proc->link.link)
00142 {
00143 pos = (PriNode *)n;
00144 break;
00145 }
00146 }
00147
00148
00149
00150 if (pos)
00151 {
00152 REMOVE(&proc->link.link);
00153 LIST_ENQUEUE(&proc_ready_list, &proc->link);
00154 }
00155 }
00156 #endif //CONFIG_KERN_PRI
00157
00158
00159 void proc_entry(void);
00160
00161
00162 void proc_switch(void);
00163
00164
00165 void proc_wakeup(Process *proc);
00166
00167
00168 void proc_schedInit(void);
00169
00170 #if CONFIG_KERN_MONITOR
00171
00172 void monitor_init(void);
00173
00175 void monitor_add(Process *proc, const char *name);
00176
00178 void monitor_remove(Process *proc);
00179
00181 void monitor_rename(Process *proc, const char *name);
00182 #endif
00183
00184
00185
00186
00187
00188
00189 #if (CONFIG_KERN && CONFIG_KERN_PREEMPT)
00190 INLINE int preempt_quantum(void)
00191 {
00192 extern int _proc_quantum;
00193 return _proc_quantum;
00194 }
00195
00196 INLINE void proc_decQuantum(void)
00197 {
00198 extern int _proc_quantum;
00199 if (_proc_quantum > 0)
00200 _proc_quantum--;
00201 }
00202
00203 INLINE void preempt_reset_quantum(void)
00204 {
00205 extern int _proc_quantum;
00206 _proc_quantum = CONFIG_KERN_QUANTUM;
00207 }
00208 #else
00209 INLINE int preempt_quantum(void)
00210 {
00211 return 0;
00212 }
00213
00214 INLINE void proc_decQuantum(void)
00215 {
00216 }
00217
00218 INLINE void preempt_reset_quantum(void)
00219 {
00220 }
00221 #endif
00222
00223 #endif