1 /* $Id: proc.h,v 1.4 1996/06/04 09:01:27 paul Exp $ */
2 #ifndef PROC_H
3 #define PROC_H
4
5 /* Here is the declaration of the process table. It contains the process'
6 * registers, memory map, accounting, and message send/receive information.
7 * Many assembly code routines reference fields in it. The offsets to these
8 * fields are defined in the assembler include file sconst.h. When changing
9 * 'proc', be sure to change sconst.h to match.
10 */
11
12 struct proc {
13 struct stackframe_s p_reg; /* process' registers saved in stack frame */
14
15 #if (CHIP == INTEL)
16 reg_t p_ldt_sel; /* selector in gdt giving ldt base and limit*/
17 struct segdesc_s p_ldt[2]; /* local descriptors for code and data */
18 /* 2 is LDT_SIZE - avoid include protect.h */
19 #endif /* (CHIP == INTEL) */
20
21 #if (CHIP == M68000)
22 reg_t p_splow; /* lowest observed stack value */
23 int p_trap; /* trap type (only low byte) */
24 #if (SHADOWING == 0)
25 char *p_crp; /* mmu table pointer (really struct _rpr *) */
26 #else
27 phys_clicks p_shadow; /* set if shadowed process image */
28 int align; /* make the struct size a multiple of 4 */
29 #endif
30 int p_nflips; /* statistics */
31 char p_physio; /* cannot be (un)shadowed now if set */
32 #if defined(FPP)
33 struct fsave p_fsave; /* FPP state frame and registers */
34 int align2; /* make the struct size a multiple of 4 */
35 #endif
36 #endif /* (CHIP == M68000) */
37
38 reg_t *p_stguard; /* stack guard word */
39
40 int p_nr; /* number of this process (for fast access) */
41
42 int p_int_blocked; /* nonzero if int msg blocked by busy task */
43 int p_int_held; /* nonzero if int msg held by busy syscall */
44 struct proc *p_nextheld; /* next in chain of held-up int processes */
45
46 int p_flags; /* P_SLOT_FREE, SENDING, RECEIVING, etc. */
47 struct mem_map p_map[NR_SEGS];/* memory map */
48 pid_t p_pid; /* process id passed in from MM */
49
50 clock_t user_time; /* user time in ticks */
51 clock_t sys_time; /* sys time in ticks */
52 clock_t child_utime; /* cumulative user time of children */
53 clock_t child_stime; /* cumulative sys time of children */
54 clock_t p_alarm; /* time of next alarm in ticks, or 0 */
55
56 struct proc *p_callerq; /* head of list of procs wishing to send */
57 struct proc *p_sendlink; /* link to next proc wishing to send */
58 message *p_messbuf; /* pointer to message buffer */
59 int p_getfrom; /* from whom does process want to receive? */
60 int p_sendto;
61
62 struct proc *p_nextready; /* pointer to next ready process */
63 sigset_t p_pending; /* bit map for pending signals */
64 unsigned p_pendcount; /* count of pending and unfinished signals */
65
66 char p_name[16]; /* name of the process */
67
68 int p_stn; /* sub-task number */
69 };
70
71 /* Guard word for task stacks. */
72 #define STACK_GUARD ((reg_t) (sizeof(reg_t) == 2 ? 0xBEEF : 0xDEADBEEF))
73
74 /* Bits for p_flags in proc[]. A process is runnable iff p_flags == 0. */
75 #define P_SLOT_FREE 001 /* set when slot is not in use */
76 #define NO_MAP 002 /* keeps unmapped forked child from running */
77 #define SENDING 004 /* set when process blocked trying to send */
78 #define RECEIVING 010 /* set when process blocked trying to recv */
79 #define PENDING 020 /* set when inform() of signal pending */
80 #define SIG_PENDING 040 /* keeps to-be-signalled proc from running */
81 #define P_STOP 0100 /* set when process is being traced */
82
83 /* Magic process table addresses. */
84 #define BEG_PROC_ADDR (&proc[0])
85 #define END_PROC_ADDR (&proc[NR_TASKS + NR_PROCS])
86 #define END_TASK_ADDR (&proc[NR_TASKS])
87 #define BEG_SERV_ADDR (&proc[NR_TASKS])
88 #define BEG_USER_ADDR (&proc[NR_TASKS + LOW_USER])
89
90 #define NIL_PROC ((struct proc *) 0)
91 #define isidlehardware(n) ((n) == IDLE || (n) == HARDWARE)
92 #define isokprocn(n) ((unsigned) ((n) + NR_TASKS) < NR_PROCS + NR_TASKS)
93 #define isoksrc_dest(n) (isokprocn(n) || (n) == ANY)
94 #define isoksusern(n) ((unsigned) (n) < NR_PROCS)
95 #define isokusern(n) ((unsigned) ((n) - LOW_USER) < NR_PROCS - LOW_USER)
96 #define isrxhardware(n) ((n) == ANY || (n) == HARDWARE)
97 #define issysentn(n) ((n) == FS_PROC_NR || (n) == MM_PROC_NR)
98 #define istaskp(p) ((p) < END_TASK_ADDR && (p) != proc_addr(IDLE))
99 #define isuserp(p) ((p) >= BEG_USER_ADDR)
100 #define proc_addr(n) (pproc_addr + NR_TASKS)[(n)]
101 #define cproc_addr(n) (&(proc + NR_TASKS)[(n)])
102 #define proc_number(p) ((p)->p_nr)
103 #if (MACHINE == SUN)
104 #define proc_vir2phys(p, vir) (umap((p), D, (vir), 1))
105 #else
106 #define proc_vir2phys(p, vir) \
107 (((phys_bytes)(p)->p_map[D].mem_phys << CLICK_SHIFT) \
108 + (vir_bytes) (vir))
109 #endif
110
111 #if (SHADOWING == 1)
112 #define isshadowp(p) ((p)->p_shadow != 0)
113 #endif
114
115 EXTERN struct proc proc[NR_TASKS + NR_PROCS]; /* process table */
116 EXTERN struct proc *pproc_addr[NR_TASKS + NR_PROCS];
117 /* ptrs to process table slots; fast because now a process entry can be found
118 by indexing the pproc_addr array, while accessing an element i requires
119 a multiplication with sizeof(struct proc) to determine the address */
120 EXTERN struct proc *bill_ptr; /* ptr to process to bill for clock ticks */
121 EXTERN struct proc *rdy_head[NQ]; /* pointers to ready list headers */
122 EXTERN struct proc *rdy_tail[NQ]; /* pointers to ready list tails */
123
124 #endif /* PROC_H */
125
This page was automatically generated by the
LXR engine.
Visit the LXR main site for more
information.