FreeBSD/Linux Kernel Cross Reference
sys/kernel/proc.h
1 #ifndef PROC_H
2 #define PROC_H
3
4 /* Here is the declaration of the process table. It contains all process
5 * data, including registers, flags, scheduling priority, memory map,
6 * accounting, message passing (IPC) information, and so on.
7 *
8 * Many assembly code routines reference fields in it. The offsets to these
9 * fields are defined in the assembler include file sconst.h. When changing
10 * struct proc, be sure to change sconst.h to match.
11 */
12 #include <minix/com.h>
13 #include "protect.h"
14 #include "const.h"
15 #include "priv.h"
16
17 struct proc {
18 struct stackframe_s p_reg; /* process' registers saved in stack frame */
19
20 #if (CHIP == INTEL)
21 reg_t p_ldt_sel; /* selector in gdt with ldt base and limit */
22 struct segdesc_s p_ldt[2+NR_REMOTE_SEGS]; /* CS, DS and remote segments */
23 #endif
24
25 #if (CHIP == M68000)
26 /* M68000 specific registers and FPU details go here. */
27 #endif
28
29 proc_nr_t p_nr; /* number of this process (for fast access) */
30 struct priv *p_priv; /* system privileges structure */
31 char p_rts_flags; /* SENDING, RECEIVING, etc. */
32
33 char p_misc_flags; /* Flags that do suspend the process */
34
35 char p_priority; /* current scheduling priority */
36 char p_max_priority; /* maximum scheduling priority */
37 char p_ticks_left; /* number of scheduling ticks left */
38 char p_quantum_size; /* quantum size in ticks */
39
40 struct mem_map p_memmap[NR_LOCAL_SEGS]; /* memory map (T, D, S) */
41
42 clock_t p_user_time; /* user time in ticks */
43 clock_t p_sys_time; /* sys time in ticks */
44
45 struct proc *p_nextready; /* pointer to next ready process */
46 struct proc *p_caller_q; /* head of list of procs wishing to send */
47 struct proc *p_q_link; /* link to next proc wishing to send */
48 message *p_messbuf; /* pointer to passed message buffer */
49 proc_nr_t p_getfrom; /* from whom does process want to receive? */
50 proc_nr_t p_sendto; /* to whom does process want to send? */
51
52 sigset_t p_pending; /* bit map for pending kernel signals */
53
54 char p_name[P_NAME_LEN]; /* name of the process, including \0 */
55
56 #if DEBUG_SCHED_CHECK
57 int p_ready, p_found;
58 #endif
59 };
60
61 /* Bits for the runtime flags. A process is runnable iff p_rts_flags == 0. */
62 #define SLOT_FREE 0x01 /* process slot is free */
63 #define NO_MAP 0x02 /* keeps unmapped forked child from running */
64 #define SENDING 0x04 /* process blocked trying to SEND */
65 #define RECEIVING 0x08 /* process blocked trying to RECEIVE */
66 #define SIGNALED 0x10 /* set when new kernel signal arrives */
67 #define SIG_PENDING 0x20 /* unready while signal being processed */
68 #define P_STOP 0x40 /* set when process is being traced */
69 #define NO_PRIV 0x80 /* keep forked system process from running */
70
71 /* Misc flags */
72 #define MF_VM 0x01 /* Process uses VM */
73
74 /* Scheduling priorities for p_priority. Values must start at zero (highest
75 * priority) and increment. Priorities of the processes in the boot image
76 * can be set in table.c. IDLE must have a queue for itself, to prevent low
77 * priority user processes to run round-robin with IDLE.
78 */
79 #define NR_SCHED_QUEUES 16 /* MUST equal minimum priority + 1 */
80 #define TASK_Q 0 /* highest, used for kernel tasks */
81 #define MAX_USER_Q 0 /* highest priority for user processes */
82 #define USER_Q 7 /* default (should correspond to nice 0) */
83 #define MIN_USER_Q 14 /* minimum priority for user processes */
84 #define IDLE_Q 15 /* lowest, only IDLE process goes here */
85
86 /* Magic process table addresses. */
87 #define BEG_PROC_ADDR (&proc[0])
88 #define BEG_USER_ADDR (&proc[NR_TASKS])
89 #define END_PROC_ADDR (&proc[NR_TASKS + NR_PROCS])
90
91 #define NIL_PROC ((struct proc *) 0)
92 #define NIL_SYS_PROC ((struct proc *) 1)
93 #define cproc_addr(n) (&(proc + NR_TASKS)[(n)])
94 #define proc_addr(n) (pproc_addr + NR_TASKS)[(n)]
95 #define proc_nr(p) ((p)->p_nr)
96
97 #define isokprocn(n) ((unsigned) ((n) + NR_TASKS) < NR_PROCS + NR_TASKS)
98 #define isemptyn(n) isemptyp(proc_addr(n))
99 #define isemptyp(p) ((p)->p_rts_flags == SLOT_FREE)
100 #define iskernelp(p) iskerneln((p)->p_nr)
101 #define iskerneln(n) ((n) < 0)
102 #define isuserp(p) isusern((p)->p_nr)
103 #define isusern(n) ((n) >= 0)
104
105 /* The process table and pointers to process table slots. The pointers allow
106 * faster access because now a process entry can be found by indexing the
107 * pproc_addr array, while accessing an element i requires a multiplication
108 * with sizeof(struct proc) to determine the address.
109 */
110 EXTERN struct proc proc[NR_TASKS + NR_PROCS]; /* process table */
111 EXTERN struct proc *pproc_addr[NR_TASKS + NR_PROCS];
112 EXTERN struct proc *rdy_head[NR_SCHED_QUEUES]; /* ptrs to ready list headers */
113 EXTERN struct proc *rdy_tail[NR_SCHED_QUEUES]; /* ptrs to ready list tails */
114
115 #endif /* PROC_H */
Cache object: dc94ff010c74f5114df2ba8931b20eb5
|