?? proc.h
字號:
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
src/kernel/proc.h
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
05100 #ifndef PROC_H
05101 #define PROC_H
05102
05103 /* Here is the declaration of the process table. It contains the process'
05104 * registers, memory map, accounting, and message send/receive information.
05105 * Many assembly code routines reference fields in it. The offsets to these
05106 * fields are defined in the assembler include file sconst.h. When changing
05107 * 'proc', be sure to change sconst.h to match.
05108 */
05109
05110 struct proc {
05111 struct stackframe_s p_reg; /* process' registers saved in stack frame */
05112
05113 #if (CHIP == INTEL)
05114 reg_t p_ldt_sel; /* selector in gdt giving ldt base and limit*/
05115 struct segdesc_s p_ldt[2]; /* local descriptors for code and data */
05116 /* 2 is LDT_SIZE - avoid include protect.h */
05117 #endif /* (CHIP == INTEL) */
05118
05119 reg_t *p_stguard; /* stack guard word */
05120
05121 int p_nr; /* number of this process (for fast access) */
05122
05123 int p_int_blocked; /* nonzero if int msg blocked by busy task */
05124 int p_int_held; /* nonzero if int msg held by busy syscall */
05125 struct proc *p_nextheld; /* next in chain of held-up int processes */
05126
05127 int p_flags; /* P_SLOT_FREE, SENDING, RECEIVING, etc. */
05128 struct mem_map p_map[NR_SEGS];/* memory map */
05129 pid_t p_pid; /* process id passed in from MM */
05130
05131 clock_t user_time; /* user time in ticks */
05132 clock_t sys_time; /* sys time in ticks */
05133 clock_t child_utime; /* cumulative user time of children */
05134 clock_t child_stime; /* cumulative sys time of children */
05135 clock_t p_alarm; /* time of next alarm in ticks, or 0 */
05136
05137 struct proc *p_callerq; /* head of list of procs wishing to send */
05138 struct proc *p_sendlink; /* link to next proc wishing to send */
05139 message *p_messbuf; /* pointer to message buffer */
05140 int p_getfrom; /* from whom does process want to receive? */
05141 int p_sendto;
05142
05143 struct proc *p_nextready; /* pointer to next ready process */
05144 sigset_t p_pending; /* bit map for pending signals */
05145 unsigned p_pendcount; /* count of pending and unfinished signals */
05146
05147 char p_name[16]; /* name of the process */
05148 };
05149
05150 /* Guard word for task stacks. */
05151 #define STACK_GUARD ((reg_t) (sizeof(reg_t) == 2 ? 0xBEEF : 0xDEADBEEF))
05152
05153 /* Bits for p_flags in proc[]. A process is runnable iff p_flags == 0. */
05154 #define P_SLOT_FREE 001 /* set when slot is not in use */
05155 #define NO_MAP 002 /* keeps unmapped forked child from running */
05156 #define SENDING 004 /* set when process blocked trying to send */
05157 #define RECEIVING 010 /* set when process blocked trying to recv */
05158 #define PENDING 020 /* set when inform() of signal pending */
05159 #define SIG_PENDING 040 /* keeps to-be-signalled proc from running */
05160 #define P_STOP 0100 /* set when process is being traced */
05161
05162 /* Magic process table addresses. */
05163 #define BEG_PROC_ADDR (&proc[0])
05164 #define END_PROC_ADDR (&proc[NR_TASKS + NR_PROCS])
05165 #define END_TASK_ADDR (&proc[NR_TASKS])
05166 #define BEG_SERV_ADDR (&proc[NR_TASKS])
05167 #define BEG_USER_ADDR (&proc[NR_TASKS + LOW_USER])
05168
05169 #define NIL_PROC ((struct proc *) 0)
05170 #define isidlehardware(n) ((n) == IDLE || (n) == HARDWARE)
05171 #define isokprocn(n) ((unsigned) ((n) + NR_TASKS) < NR_PROCS + NR_TASKS)
05172 #define isoksrc_dest(n) (isokprocn(n) || (n) == ANY)
05173 #define isoksusern(n) ((unsigned) (n) < NR_PROCS)
05174 #define isokusern(n) ((unsigned) ((n) - LOW_USER) < NR_PROCS - LOW_USER)
05175 #define isrxhardware(n) ((n) == ANY || (n) == HARDWARE)
05176 #define issysentn(n) ((n) == FS_PROC_NR || (n) == MM_PROC_NR)
05177 #define istaskp(p) ((p) < END_TASK_ADDR && (p) != proc_addr(IDLE))
05178 #define isuserp(p) ((p) >= BEG_USER_ADDR)
05179 #define proc_addr(n) (pproc_addr + NR_TASKS)[(n)]
05180 #define cproc_addr(n) (&(proc + NR_TASKS)[(n)])
05181 #define proc_number(p) ((p)->p_nr)
05182 #define proc_vir2phys(p, vir) \
05183 (((phys_bytes)(p)->p_map[D].mem_phys << CLICK_SHIFT) \
05184 + (vir_bytes) (vir))
05185
05186 EXTERN struct proc proc[NR_TASKS + NR_PROCS]; /* process table */
05187 EXTERN struct proc *pproc_addr[NR_TASKS + NR_PROCS];
05188 /* ptrs to process table slots; fast because now a process entry can be found
05189 by indexing the pproc_addr array, while accessing an element i requires
05190 a multiplication with sizeof(struct proc) to determine the address */
05191 EXTERN struct proc *bill_ptr; /* ptr to process to bill for clock ticks */
05192 EXTERN struct proc *rdy_head[NQ]; /* pointers to ready list headers */
05193 EXTERN struct proc *rdy_tail[NQ]; /* pointers to ready list tails */
05194
05195 #endif /* PROC_H */
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -