2005-04-21 16:53:53 +02:00
|
|
|
#ifndef PROC_H
|
|
|
|
#define PROC_H
|
|
|
|
|
2005-06-24 18:24:40 +02:00
|
|
|
/* Here is the declaration of the process table. It contains all process
|
|
|
|
* data, including registers, flags, scheduling priority, memory map,
|
|
|
|
* accounting, message passing (IPC) information, and so on.
|
|
|
|
*
|
2005-04-21 16:53:53 +02:00
|
|
|
* Many assembly code routines reference fields in it. The offsets to these
|
|
|
|
* fields are defined in the assembler include file sconst.h. When changing
|
2005-06-24 18:24:40 +02:00
|
|
|
* struct proc, be sure to change sconst.h to match.
|
2005-04-21 16:53:53 +02:00
|
|
|
*/
|
|
|
|
#include <minix/com.h>
|
2005-04-29 17:36:43 +02:00
|
|
|
#include "protect.h"
|
2005-04-21 16:53:53 +02:00
|
|
|
#include "const.h"
|
2005-07-14 17:12:12 +02:00
|
|
|
#include "priv.h"
|
2005-04-21 16:53:53 +02:00
|
|
|
|
|
|
|
struct proc {
|
|
|
|
struct stackframe_s p_reg; /* process' registers saved in stack frame */
|
|
|
|
|
|
|
|
#if (CHIP == INTEL)
|
2005-05-24 16:35:58 +02:00
|
|
|
reg_t p_ldt_sel; /* selector in gdt with ldt base and limit */
|
2005-04-29 17:36:43 +02:00
|
|
|
struct segdesc_s p_ldt[2+NR_REMOTE_SEGS]; /* CS, DS and remote segments */
|
2005-06-24 18:24:40 +02:00
|
|
|
#endif
|
2005-04-21 16:53:53 +02:00
|
|
|
|
|
|
|
#if (CHIP == M68000)
|
|
|
|
/* M68000 specific registers and FPU details go here. */
|
2005-06-24 18:24:40 +02:00
|
|
|
#endif
|
2005-04-21 16:53:53 +02:00
|
|
|
|
2005-05-19 11:36:44 +02:00
|
|
|
proc_nr_t p_nr; /* number of this process (for fast access) */
|
2005-07-14 17:12:12 +02:00
|
|
|
struct priv *p_priv; /* system privileges structure */
|
2006-03-10 17:10:05 +01:00
|
|
|
short p_rts_flags; /* process is runnable only if zero */
|
|
|
|
short p_misc_flags; /* flags that do suspend the process */
|
2005-09-30 14:54:59 +02:00
|
|
|
|
2005-06-24 18:24:40 +02:00
|
|
|
char p_priority; /* current scheduling priority */
|
2005-06-30 17:55:19 +02:00
|
|
|
char p_max_priority; /* maximum scheduling priority */
|
2005-08-22 17:14:11 +02:00
|
|
|
char p_ticks_left; /* number of scheduling ticks left */
|
2005-08-23 14:53:35 +02:00
|
|
|
char p_quantum_size; /* quantum size in ticks */
|
2005-04-21 16:53:53 +02:00
|
|
|
|
2005-07-14 17:12:12 +02:00
|
|
|
struct mem_map p_memmap[NR_LOCAL_SEGS]; /* memory map (T, D, S) */
|
2005-06-30 17:55:19 +02:00
|
|
|
|
2005-05-31 11:50:51 +02:00
|
|
|
clock_t p_user_time; /* user time in ticks */
|
|
|
|
clock_t p_sys_time; /* sys time in ticks */
|
2005-04-21 16:53:53 +02:00
|
|
|
|
2005-05-24 16:35:58 +02:00
|
|
|
struct proc *p_nextready; /* pointer to next ready process */
|
2005-05-19 16:05:51 +02:00
|
|
|
struct proc *p_caller_q; /* head of list of procs wishing to send */
|
2005-05-26 15:17:57 +02:00
|
|
|
struct proc *p_q_link; /* link to next proc wishing to send */
|
2005-05-31 16:43:04 +02:00
|
|
|
message *p_messbuf; /* pointer to passed message buffer */
|
'proc number' is process slot, 'endpoint' are generation-aware process
instance numbers, encoded and decoded using macros in <minix/endpoint.h>.
proc number -> endpoint migration
. proc_nr in the interrupt hook is now an endpoint, proc_nr_e.
. m_source for messages and notifies is now an endpoint, instead of
proc number.
. isokendpt() converts an endpoint to a process number, returns
success (but fails if the process number is out of range, the
process slot is not a living process, or the given endpoint
number does not match the endpoint number in the process slot,
indicating an old process).
. okendpt() is the same as isokendpt(), but panic()s if the conversion
fails. This is mainly used for decoding message.m_source endpoints,
and other endpoint numbers in kernel data structures, which should
always be correct.
. if DEBUG_ENABLE_IPC_WARNINGS is enabled, isokendpt() and okendpt()
get passed the __FILE__ and __LINE__ of the calling lines, and
print messages about what is wrong with the endpoint number
(out of range proc, empty proc, or inconsistent endpoint number),
with the caller, making finding where the conversion failed easy
without having to include code for every call to print where things
went wrong. Sometimes this is harmless (wrong arg to a kernel call),
sometimes it's a fatal internal inconsistency (bogus m_source).
. some process table fields have been appended an _e to indicate it's
become and endpoint.
. process endpoint is stored in p_endpoint, without generation number.
it turns out the kernel never needs the generation number, except
when fork()ing, so it's decoded then.
. kernel calls all take endpoints as arguments, not proc numbers.
the one exception is sys_fork(), which needs to know in which slot
to put the child.
2006-03-03 11:00:02 +01:00
|
|
|
int p_getfrom_e; /* from whom does process want to receive? */
|
|
|
|
int p_sendto_e; /* to whom does process want to send? */
|
2005-05-24 12:06:17 +02:00
|
|
|
|
2005-05-31 16:43:04 +02:00
|
|
|
sigset_t p_pending; /* bit map for pending kernel signals */
|
2005-04-21 16:53:53 +02:00
|
|
|
|
2005-05-31 11:50:51 +02:00
|
|
|
char p_name[P_NAME_LEN]; /* name of the process, including \0 */
|
2005-05-24 14:32:34 +02:00
|
|
|
|
'proc number' is process slot, 'endpoint' are generation-aware process
instance numbers, encoded and decoded using macros in <minix/endpoint.h>.
proc number -> endpoint migration
. proc_nr in the interrupt hook is now an endpoint, proc_nr_e.
. m_source for messages and notifies is now an endpoint, instead of
proc number.
. isokendpt() converts an endpoint to a process number, returns
success (but fails if the process number is out of range, the
process slot is not a living process, or the given endpoint
number does not match the endpoint number in the process slot,
indicating an old process).
. okendpt() is the same as isokendpt(), but panic()s if the conversion
fails. This is mainly used for decoding message.m_source endpoints,
and other endpoint numbers in kernel data structures, which should
always be correct.
. if DEBUG_ENABLE_IPC_WARNINGS is enabled, isokendpt() and okendpt()
get passed the __FILE__ and __LINE__ of the calling lines, and
print messages about what is wrong with the endpoint number
(out of range proc, empty proc, or inconsistent endpoint number),
with the caller, making finding where the conversion failed easy
without having to include code for every call to print where things
went wrong. Sometimes this is harmless (wrong arg to a kernel call),
sometimes it's a fatal internal inconsistency (bogus m_source).
. some process table fields have been appended an _e to indicate it's
become and endpoint.
. process endpoint is stored in p_endpoint, without generation number.
it turns out the kernel never needs the generation number, except
when fork()ing, so it's decoded then.
. kernel calls all take endpoints as arguments, not proc numbers.
the one exception is sys_fork(), which needs to know in which slot
to put the child.
2006-03-03 11:00:02 +01:00
|
|
|
int p_endpoint; /* endpoint number, generation-aware */
|
|
|
|
|
2005-07-14 17:12:12 +02:00
|
|
|
#if DEBUG_SCHED_CHECK
|
2005-05-24 14:32:34 +02:00
|
|
|
int p_ready, p_found;
|
|
|
|
#endif
|
2005-04-21 16:53:53 +02:00
|
|
|
};
|
|
|
|
|
2005-06-30 17:55:19 +02:00
|
|
|
/* Bits for the runtime flags. A process is runnable iff p_rts_flags == 0. */
|
2005-06-24 18:24:40 +02:00
|
|
|
#define SLOT_FREE 0x01 /* process slot is free */
|
2006-05-11 16:49:46 +02:00
|
|
|
#define NO_PRIORITY 0x02 /* process has been stopped */
|
2006-03-10 17:10:05 +01:00
|
|
|
#define SENDING 0x04 /* process blocked trying to send */
|
|
|
|
#define RECEIVING 0x08 /* process blocked trying to receive */
|
2005-06-24 18:24:40 +02:00
|
|
|
#define SIGNALED 0x10 /* set when new kernel signal arrives */
|
|
|
|
#define SIG_PENDING 0x20 /* unready while signal being processed */
|
2005-05-26 15:17:57 +02:00
|
|
|
#define P_STOP 0x40 /* set when process is being traced */
|
2005-08-02 17:28:09 +02:00
|
|
|
#define NO_PRIV 0x80 /* keep forked system process from running */
|
2006-05-11 16:49:46 +02:00
|
|
|
#define NO_ENDPOINT 0x100 /* process cannot send or receive messages */
|
2005-06-24 18:24:40 +02:00
|
|
|
|
2005-09-30 14:54:59 +02:00
|
|
|
/* Misc flags */
|
2006-03-10 17:10:05 +01:00
|
|
|
#define REPLY_PENDING 0x01 /* reply to IPC_REQUEST is pending */
|
|
|
|
#define MF_VM 0x08 /* process uses VM */
|
2005-09-30 14:54:59 +02:00
|
|
|
|
2005-06-24 18:24:40 +02:00
|
|
|
/* Scheduling priorities for p_priority. Values must start at zero (highest
|
2005-08-19 18:43:28 +02:00
|
|
|
* priority) and increment. Priorities of the processes in the boot image
|
|
|
|
* can be set in table.c. IDLE must have a queue for itself, to prevent low
|
|
|
|
* priority user processes to run round-robin with IDLE.
|
2005-04-21 16:53:53 +02:00
|
|
|
*/
|
2005-07-01 11:08:41 +02:00
|
|
|
#define NR_SCHED_QUEUES 16 /* MUST equal minimum priority + 1 */
|
2005-08-19 18:43:28 +02:00
|
|
|
#define TASK_Q 0 /* highest, used for kernel tasks */
|
|
|
|
#define MAX_USER_Q 0 /* highest priority for user processes */
|
|
|
|
#define USER_Q 7 /* default (should correspond to nice 0) */
|
2005-07-01 11:08:41 +02:00
|
|
|
#define MIN_USER_Q 14 /* minimum priority for user processes */
|
|
|
|
#define IDLE_Q 15 /* lowest, only IDLE process goes here */
|
2005-04-21 16:53:53 +02:00
|
|
|
|
|
|
|
/* Magic process table addresses. */
|
|
|
|
#define BEG_PROC_ADDR (&proc[0])
|
|
|
|
#define BEG_USER_ADDR (&proc[NR_TASKS])
|
|
|
|
#define END_PROC_ADDR (&proc[NR_TASKS + NR_PROCS])
|
|
|
|
|
2005-07-19 14:21:36 +02:00
|
|
|
#define NIL_PROC ((struct proc *) 0)
|
2005-07-20 17:25:38 +02:00
|
|
|
#define NIL_SYS_PROC ((struct proc *) 1)
|
2005-06-07 14:34:25 +02:00
|
|
|
#define cproc_addr(n) (&(proc + NR_TASKS)[(n)])
|
|
|
|
#define proc_addr(n) (pproc_addr + NR_TASKS)[(n)]
|
|
|
|
#define proc_nr(p) ((p)->p_nr)
|
|
|
|
|
2005-04-21 16:53:53 +02:00
|
|
|
#define isokprocn(n) ((unsigned) ((n) + NR_TASKS) < NR_PROCS + NR_TASKS)
|
2005-06-30 17:55:19 +02:00
|
|
|
#define isemptyn(n) isemptyp(proc_addr(n))
|
|
|
|
#define isemptyp(p) ((p)->p_rts_flags == SLOT_FREE)
|
|
|
|
#define iskernelp(p) iskerneln((p)->p_nr)
|
|
|
|
#define iskerneln(n) ((n) < 0)
|
|
|
|
#define isuserp(p) isusern((p)->p_nr)
|
|
|
|
#define isusern(n) ((n) >= 0)
|
2005-06-07 14:34:25 +02:00
|
|
|
|
2005-04-21 16:53:53 +02:00
|
|
|
/* The process table and pointers to process table slots. The pointers allow
|
|
|
|
* faster access because now a process entry can be found by indexing the
|
|
|
|
* pproc_addr array, while accessing an element i requires a multiplication
|
|
|
|
* with sizeof(struct proc) to determine the address.
|
|
|
|
*/
|
|
|
|
EXTERN struct proc proc[NR_TASKS + NR_PROCS]; /* process table */
|
|
|
|
EXTERN struct proc *pproc_addr[NR_TASKS + NR_PROCS];
|
|
|
|
EXTERN struct proc *rdy_head[NR_SCHED_QUEUES]; /* ptrs to ready list headers */
|
|
|
|
EXTERN struct proc *rdy_tail[NR_SCHED_QUEUES]; /* ptrs to ready list tails */
|
|
|
|
|
|
|
|
#endif /* PROC_H */
|