1: /*
   2:  * Copyright (c) 1986 Regents of the University of California.
   3:  * All rights reserved.  The Berkeley software License Agreement
   4:  * specifies the terms and conditions for redistribution.
   5:  *
   6:  *	@(#)proc.h	1.5 (2.11BSD) 1999/9/5
   7:  */
   8: 
   9: #ifndef _SYS_PROC_H_
  10: #define _SYS_PROC_H_
  11: 
  12: /*
  13:  * One structure allocated per active
  14:  * process. It contains all data needed
  15:  * about the process while the
  16:  * process may be swapped out.
  17:  * Other per process data (user.h)
  18:  * is swapped with the process.
  19:  */
  20: struct  proc {
  21:     struct  proc *p_nxt;    /* linked list of allocated proc slots */
  22:     struct  proc **p_prev;  /* also zombies, and free proc's */
  23:     struct  proc *p_pptr;   /* pointer to process structure of parent */
  24:     short   p_flag;
  25:     short   p_uid;      /* user id, used to direct tty signals */
  26:     short   p_pid;      /* unique process id */
  27:     short   p_ppid;     /* process id of parent */
  28:     long    p_sig;      /* signals pending to this process */
  29:     char    p_stat;
  30:     char    p_dummy;    /* room for one more, here */
  31: 
  32:     /*
  33: 	 * Union to overwrite information no longer needed by ZOMBIED
  34: 	 * process with exit information for the parent process.  The
  35: 	 * two structures have been carefully set up to use the same
  36: 	 * amount of memory.  Must be very careful that any values in
  37: 	 * p_alive are not used for zombies (zombproc).
  38: 	 */
  39:     union {
  40:         struct {
  41:         char    P_pri;      /* priority, negative is high */
  42:         char    P_cpu;      /* cpu usage for scheduling */
  43:         char    P_time;     /* resident time for scheduling */
  44:         char    P_nice;     /* nice for cpu usage */
  45:         char    P_slptime;  /* secs sleeping */
  46:         char    P_ptracesig;    /* used between parent & traced child */
  47:         struct proc *P_hash;    /* hashed based on p_pid */
  48:         long    P_sigmask;  /* current signal mask */
  49:         long    P_sigignore;    /* signals being ignored */
  50:         long    P_sigcatch; /* signals being caught by user */
  51:         short   P_pgrp;     /* name of process group leader */
  52:         struct  proc *P_link;   /* linked list of running processes */
  53:         memaddr P_addr;     /* address of u. area */
  54:         memaddr P_daddr;    /* address of data area */
  55:         memaddr P_saddr;    /* address of stack area */
  56:         size_t  P_dsize;    /* size of data area (clicks) */
  57:         size_t  P_ssize;    /* size of stack segment (clicks) */
  58:         caddr_t P_wchan;    /* event process is awaiting */
  59:         struct  text *P_textp;  /* pointer to text structure */
  60:         struct  k_itimerval P_realtimer;
  61:         } p_alive;
  62:         struct {
  63:         short   P_xstat;    /* exit status for wait */
  64:         struct k_rusage P_ru;   /* exit information */
  65:         } p_dead;
  66:     } p_un;
  67: };
  68: #define p_pri       p_un.p_alive.P_pri
  69: #define p_cpu       p_un.p_alive.P_cpu
  70: #define p_time      p_un.p_alive.P_time
  71: #define p_nice      p_un.p_alive.P_nice
  72: #define p_slptime   p_un.p_alive.P_slptime
  73: #define p_hash      p_un.p_alive.P_hash
  74: #define p_ptracesig p_un.p_alive.P_ptracesig
  75: #define p_sigmask   p_un.p_alive.P_sigmask
  76: #define p_sigignore p_un.p_alive.P_sigignore
  77: #define p_sigcatch  p_un.p_alive.P_sigcatch
  78: #define p_pgrp      p_un.p_alive.P_pgrp
  79: #define p_link      p_un.p_alive.P_link
  80: #define p_addr      p_un.p_alive.P_addr
  81: #define p_daddr     p_un.p_alive.P_daddr
  82: #define p_saddr     p_un.p_alive.P_saddr
  83: #define p_dsize     p_un.p_alive.P_dsize
  84: #define p_ssize     p_un.p_alive.P_ssize
  85: #define p_wchan     p_un.p_alive.P_wchan
  86: #define p_textp     p_un.p_alive.P_textp
  87: #define p_realtimer p_un.p_alive.P_realtimer
  88: #define p_clktim    p_realtimer.it_value
  89: 
  90: #define p_xstat     p_un.p_dead.P_xstat
  91: #define p_ru        p_un.p_dead.P_ru
  92: 
  93: #define PIDHSZ      16
  94: #define PIDHASH(pid)    ((pid) & (PIDHSZ - 1))
  95: 
  96: #if defined(KERNEL) && !defined(SUPERVISOR)
  97: struct  proc *pidhash[PIDHSZ];
  98: struct  proc *pfind();
  99: struct  proc proc[], *procNPROC;    /* the proc table itself */
 100: struct  proc *freeproc, *zombproc, *allproc, *qs;
 101:             /* lists of procs in various states */
 102: int nproc;
 103: #endif
 104: 
 105: /* stat codes */
 106: #define SSLEEP  1       /* awaiting an event */
 107: #define SWAIT   2       /* (abandoned state) */
 108: #define SRUN    3       /* running */
 109: #define SIDL    4       /* intermediate state in process creation */
 110: #define SZOMB   5       /* intermediate state in process termination */
 111: #define SSTOP   6       /* process being traced */
 112: 
 113: /* flag codes */
 114: #define SLOAD       0x0001  /* in core */
 115: #define SSYS        0x0002  /* swapper or pager process */
 116: #define SLOCK       0x0004  /* process being swapped out */
 117: #define SSWAP       0x0008  /* save area flag */
 118: #define P_TRACED    0x0010  /* process is being traced */
 119: #define P_WAITED    0x0020  /* another tracing flag */
 120: #define SULOCK      0x0040  /* user settable lock in core */
 121: #define P_SINTR     0x0080  /* sleeping interruptibly */
 122: #define SVFORK      0x0100  /* process resulted from vfork() */
 123: #define SVFPRNT     0x0200  /* parent in vfork, waiting for child */
 124: #define SVFDONE     0x0400  /* parent has released child in vfork */
 125:     /*		0x0800	/* unused */
 126: #define P_TIMEOUT   0x1000  /* tsleep timeout expired */
 127: #define P_NOCLDSTOP 0x2000  /* no SIGCHLD signal to parent */
 128: #define P_SELECT    0x4000  /* selecting; wakeup/waiting danger */
 129:     /*		0x8000	/* unused */
 130: 
 131: #define S_DATA  0       /* specified segment */
 132: #define S_STACK 1
 133: 
 134: #endif	/* !_SYS_PROC_H_ */

Defined variables

freeproc defined in line 100; used 8 times
procNPROC defined in line 99; used 2 times
qs defined in line 100; used 9 times

Defined struct's

proc defined in line 20; used 392 times

Defined macros

PIDHSZ defined in line 93; used 2 times
P_NOCLDSTOP defined in line 127; used 5 times
P_SELECT defined in line 128; used 7 times
P_TIMEOUT defined in line 126; used 3 times
SIDL defined in line 109; used 3 times
SVFDONE defined in line 124; used 3 times
SVFPRNT defined in line 123; used 4 times
SWAIT defined in line 107; never used
_SYS_PROC_H_ defined in line 10; used 1 times
  • in line 9
p_clktim defined in line 88; used 1 times
p_link defined in line 79; used 19 times
p_realtimer defined in line 87; used 12 times
p_ru defined in line 91; used 4 times
p_xstat defined in line 90; used 4 times

Usage of this include

proc.h used 72 times
Last modified: 1999-09-06
Generated: 2016-12-26
Generated by src2html V0.67
page hit count: 5188
Valid CSS Valid XHTML 1.0 Strict