source: trunk/minix/kernel/proc.h@ 11

Last change on this file since 11 was 9, checked in by Mattia Monga, 14 years ago

Minix 3.1.2a

File size: 4.9 KB
RevLine 
[9]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
17struct 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 short p_rts_flags; /* process is runnable only if zero */
32 short p_misc_flags; /* flags that do suspend the process */
33
34 char p_priority; /* current scheduling priority */
35 char p_max_priority; /* maximum scheduling priority */
36 char p_ticks_left; /* number of scheduling ticks left */
37 char p_quantum_size; /* quantum size in ticks */
38
39 struct mem_map p_memmap[NR_LOCAL_SEGS]; /* memory map (T, D, S) */
40
41 clock_t p_user_time; /* user time in ticks */
42 clock_t p_sys_time; /* sys time in ticks */
43
44 struct proc *p_nextready; /* pointer to next ready process */
45 struct proc *p_caller_q; /* head of list of procs wishing to send */
46 struct proc *p_q_link; /* link to next proc wishing to send */
47 message *p_messbuf; /* pointer to passed message buffer */
48 int p_getfrom_e; /* from whom does process want to receive? */
49 int p_sendto_e; /* to whom does process want to send? */
50
51 sigset_t p_pending; /* bit map for pending kernel signals */
52
53 char p_name[P_NAME_LEN]; /* name of the process, including \0 */
54
55 int p_endpoint; /* endpoint number, generation-aware */
56
57#if DEBUG_SCHED_CHECK
58 int p_ready, p_found;
59#endif
60};
61
62/* Bits for the runtime flags. A process is runnable iff p_rts_flags == 0. */
63#define SLOT_FREE 0x01 /* process slot is free */
64#define NO_MAP 0x02 /* keeps unmapped forked child from running */
65#define SENDING 0x04 /* process blocked trying to send */
66#define RECEIVING 0x08 /* process blocked trying to receive */
67#define SIGNALED 0x10 /* set when new kernel signal arrives */
68#define SIG_PENDING 0x20 /* unready while signal being processed */
69#define P_STOP 0x40 /* set when process is being traced */
70#define NO_PRIV 0x80 /* keep forked system process from running */
71#define NO_PRIORITY 0x100 /* process has been stopped */
72#define NO_ENDPOINT 0x200 /* process cannot send or receive messages */
73
74/* Misc flags */
75#define REPLY_PENDING 0x01 /* reply to IPC_REQUEST is pending */
76#define MF_VM 0x08 /* process uses VM */
77
78/* Scheduling priorities for p_priority. Values must start at zero (highest
79 * priority) and increment. Priorities of the processes in the boot image
80 * can be set in table.c. IDLE must have a queue for itself, to prevent low
81 * priority user processes to run round-robin with IDLE.
82 */
83#define NR_SCHED_QUEUES 16 /* MUST equal minimum priority + 1 */
84#define TASK_Q 0 /* highest, used for kernel tasks */
85#define MAX_USER_Q 0 /* highest priority for user processes */
86#define USER_Q 7 /* default (should correspond to nice 0) */
87#define MIN_USER_Q 14 /* minimum priority for user processes */
88#define IDLE_Q 15 /* lowest, only IDLE process goes here */
89
90/* Magic process table addresses. */
91#define BEG_PROC_ADDR (&proc[0])
92#define BEG_USER_ADDR (&proc[NR_TASKS])
93#define END_PROC_ADDR (&proc[NR_TASKS + NR_PROCS])
94
95#define NIL_PROC ((struct proc *) 0)
96#define NIL_SYS_PROC ((struct proc *) 1)
97#define cproc_addr(n) (&(proc + NR_TASKS)[(n)])
98#define proc_addr(n) (pproc_addr + NR_TASKS)[(n)]
99#define proc_nr(p) ((p)->p_nr)
100
101#define isokprocn(n) ((unsigned) ((n) + NR_TASKS) < NR_PROCS + NR_TASKS)
102#define isemptyn(n) isemptyp(proc_addr(n))
103#define isemptyp(p) ((p)->p_rts_flags == SLOT_FREE)
104#define iskernelp(p) iskerneln((p)->p_nr)
105#define iskerneln(n) ((n) < 0)
106#define isuserp(p) isusern((p)->p_nr)
107#define isusern(n) ((n) >= 0)
108
109/* The process table and pointers to process table slots. The pointers allow
110 * faster access because now a process entry can be found by indexing the
111 * pproc_addr array, while accessing an element i requires a multiplication
112 * with sizeof(struct proc) to determine the address.
113 */
114EXTERN struct proc proc[NR_TASKS + NR_PROCS]; /* process table */
115EXTERN struct proc *pproc_addr[NR_TASKS + NR_PROCS];
116EXTERN struct proc *rdy_head[NR_SCHED_QUEUES]; /* ptrs to ready list headers */
117EXTERN struct proc *rdy_tail[NR_SCHED_QUEUES]; /* ptrs to ready list tails */
118
119#endif /* PROC_H */
Note: See TracBrowser for help on using the repository browser.