home *** CD-ROM | disk | FTP | other *** search
/ Piper's Pit BBS/FTP: ibm 0010 - 0019 / ibm0010-0019 / ibm0010.tar / ibm0010 / UNIX3862.ZIP / U386-06.ZIP / U386-6.TD0 / usr / include / sys / proc.h < prev    next >
Encoding:
C/C++ Source or Header  |  1988-06-26  |  6.1 KB  |  161 lines

  1. /*    Copyright (c) 1984, 1986, 1987, 1988 AT&T    */
  2. /*      All Rights Reserved      */
  3.  
  4. /*    THIS IS UNPUBLISHED PROPRIETARY SOURCE CODE OF AT&T    */
  5. /*    The copyright notice above does not evidence any       */
  6. /*    actual or intended publication of such source code.    */
  7.  
  8. /*    Copyright (c) 1987, 1988 Microsoft Corporation    */
  9. /*      All Rights Reserved    */
  10.  
  11. /*    This Module contains Proprietary Information of Microsoft  */
  12. /*    Corporation and should be treated as Confidential.       */
  13.  
  14. #ident    "@(#)head.sys:proc.h    1.3.1.3"
  15.  
  16. /*    One structure allocated per active process. It contains all
  17. **    data needed about the process while the process may be swapped
  18. **    out.  Other per process data (user.h) may swapped with the
  19. **    process but in fact it is not.
  20. */
  21.  
  22. typedef struct    proc {
  23.     char    p_stat;            /* status of process */
  24.     char    p_pri;            /* priority, negative is high */
  25.     char    p_cpu;            /* cpu usage for scheduling */
  26.     char    p_nice;            /* nice for cpu usage */
  27.     uint    p_flag;            /* flags defined below */
  28.     ushort    p_uid;            /* real user id */
  29.     ushort    p_suid;            /* saved (effective) uid from exec */
  30.     short    p_pgrp;            /* name of process group leader */
  31.     short    p_pid;            /* unique process id*/
  32.     short    p_ppid;            /* process id of parent*/
  33.     ushort    p_sgid;            /* saved (effective) gid from exec */
  34.     int    p_sig;            /* signals pending to this process */
  35.     struct    proc    *p_flink;    /* forward link */
  36.     struct    proc    *p_blink;    /* backward link */
  37.     union {                /* wait addr for sleeping processes */
  38.         caddr_t    p_cad;        /* Union is for XENIX compatibility */
  39.         int    p_int;
  40.     } p_unw;
  41. #define    p_wchan    p_unw.p_cad        /* Map MP name to old UNIX name */
  42. #define    p_arg    p_unw.p_int        /* Map MP name to old UNIX name */
  43.     struct    proc    *p_parent;    /* ptr to parent process */
  44.     struct    proc    *p_child;    /* ptr to first child process */
  45.     struct    proc    *p_sibling;    /* ptr to next sibling proc on chain */
  46.     int    p_clktim;        /* time to alarm clock signal */
  47.     uint    p_size;            /* size of swappable image in pages */
  48.     time_t    p_utime;        /* user time, this process */
  49.     time_t    p_stime;        /* system time, this process */
  50.     struct  proc *p_mlink;        /* linked list of processes sleeping
  51.                      * on memwant or swapwant
  52.                      */
  53.     ushort    p_usize;        /* size of u-block (*4096 bytes) */
  54.     ushort    p_res1;            /* Pad because p_usize is replacing
  55.                      * a paddr_t (i.e., long) field, and
  56.                      * it is only a short.
  57.                      */
  58.     caddr_t    p_ldt;            /* address of ldt */
  59.     long    p_res2;            /* Pad because a 'pde_t *' field was
  60.                      * removed here.  Its function is
  61.                      * replaced by p_ubptbl[MAXUSIZE].
  62.                      */
  63.  
  64.     preg_t    *p_region;        /* process regions */
  65.     ushort    p_mpgneed;        /* number of memory pages needed in
  66.                      * memwant.
  67.                      */
  68.     char    p_time;            /* resident time for scheduling */
  69.     unchar    p_cursig;        /* current signal */
  70.     short    p_epid;            /* effective pid; normally same as
  71.                      * p_pid; for servers, the system that
  72.                      * sent the msg
  73.                      */
  74.     sysid_t p_sysid;        /* normally same as sysid; for servers,
  75.                      * the system that sent the msg
  76.                      */
  77.     struct    rcvd  *p_minwd;        /* server msg arrived on this queue */
  78.     struct    proc  *p_rlink;        /* linked list for server */
  79.     int    p_trlock;
  80.     struct    inode *p_trace;        /* pointer to /proc inode */
  81.     long    p_sigmask;        /* tracing signal mask for /proc */
  82.     int    p_hold;            /* hold signal bit mask */
  83.     int    p_chold;        /* deferred signal bit mask; sigset(2)
  84.                      * turns these bits on while signal(2)
  85.                      * does not.
  86.                      */
  87.     short    p_xstat;        /* exit status for wait */
  88.     struct  v86dat *p_v86;          /* pointer to v86 structure */
  89.     dbd_t    p_ubdbd;        /* DBD for ublock when swapped out */
  90.     ushort    p_whystop;        /* Reason for process stop */
  91.     ushort    p_whatstop;        /* More detailed reason */
  92.     pde_t    p_ubptbl[MAXUSIZE];    /* u-block page table entries */
  93.     struct    sd *p_sdp;        /* pointer to XENIX shared data */
  94. } proc_t;
  95.  
  96. #define    p_link    p_flink
  97.  
  98. extern struct proc proc[];        /* the proc table itself */
  99.  
  100. /* stat codes */
  101.  
  102. #define    SSLEEP    1        /* awaiting an event */
  103. #define    SRUN    2        /* running */
  104. #define    SZOMB    3        /* process terminated but not waited for */
  105. #define    SSTOP    4        /* process stopped by debugger */
  106. #define    SIDL    5        /* intermediate state in process creation */
  107. #define    SONPROC    6        /* process is being run on a processor */
  108. #define SXBRK    7        /* process being xswapped */
  109.  
  110. /* flag codes */
  111.  
  112. #define    SSYS    0x00000001    /* system (resident) process */
  113. #define    STRC    0x00000002    /* process is being traced */
  114. #define    SWTED    0x00000004    /* ptraced process has been given to parent
  115.                  * by wait(2); don't return this process to
  116.                  * parent again until it runs first.
  117.                  */
  118. #define    SNWAKE    0x00000008    /* process cannot be awakened by a signal */
  119. #define    SLOAD    0x00000010    /* in core */
  120. #define    SLOCK   0x00000020    /* process cannot be swapped */
  121. #define    SRSIG    0x00000040    /* set when signal goes remote */
  122. #define    SPOLL    0x00000080    /* process in stream poll */
  123. #define    SPRSTOP    0x00000100    /* process is being stopped via /proc */
  124. #define    SPROCTR    0x00000200    /* signal or syscall tracing via /proc */
  125. #define    SPROCIO    0x00000400    /* doing I/O via /proc, so don't run */
  126. #define    SSEXEC    0x00000800    /* stop on exec */
  127. #define    SPROPEN    0x00001000    /* process is open via /proc */
  128. #define    SULOAD  0x00002000    /* u-block in core */
  129. #define    SRUNLCL    0x00004000    /* set process running on last /proc close */
  130. #define    SNOSTOP    0x00008000    /* proc asleep, stop not allowed */
  131. #define    SPTRX    0x00010000    /* process is exiting via ptrace(2) */
  132. #define    SASLEEP    0x00020000    /* proc is stopped within a call to sleep() */
  133. #define    SUSWAP    0x00040000    /* u-block is being swapped in or out */
  134. #define    SUWANT    0x00080000    /* waiting for u-block swap to complete */
  135.  
  136. #define PTRACED(p)    ((p)->p_flag&(STRC|SPROCTR|SSEXEC|SPROPEN))
  137.  
  138. #define    ubptbl(PP)    ((PP)->p_ubptbl)
  139. /* Flags for newproc() */
  140.  
  141. #define NP_FAILOK    0x1    /* don't panic if cannot create process */
  142. #define NP_NOLAST    0x2    /* don't use last process slot */
  143. #define    NP_SYSPROC    0x4    /* system (resident) process */
  144.  
  145. /* Reasons for stopping (values of p_whystop) */
  146.  
  147. #define    REQUESTED    1
  148. #define    SIGNALLED    2
  149. #define    SYSENTRY    3
  150. #define    SYSEXIT        4
  151.  
  152. /* Macro to reduce unnecessary calls to issig() */
  153.  
  154. #define    ISSIG(p, why) \
  155.   ((p)->p_cursig || (((p)->p_sig || ((p)->p_flag & SPRSTOP)) && issig(why)))
  156.  
  157. /* Reasons for calling issig() */
  158.  
  159. #define    FORREAL        0    /* Usual side-effects */
  160. #define    JUSTLOOKING    1    /* Don't stop the process */
  161.