home *** CD-ROM | disk | FTP | other *** search
/ Media Share 9 / MEDIASHARE_09.ISO / hamradio / s920603.zip / PROC.H < prev    next >
C/C++ Source or Header  |  1992-05-19  |  4KB  |  118 lines

  1. #ifndef    _PROC_H
  2. #define    _PROC_H
  3.  
  4. #include <setjmp.h>
  5.  
  6. #ifndef _MBUF_H
  7. #include "mbuf.h"
  8. #endif
  9.  
  10. #ifndef    _TIMER_H
  11. #include "timer.h"
  12. #endif
  13.  
  14. #define    SIGQSIZE    200    /* Entries in psignal queue */
  15.  
  16. /* Kernel process control block */
  17. #define    PHASH    16        /* Number of wait table hash chains */
  18. struct proc {
  19.     struct proc *prev;    /* Process table pointers */
  20.     struct proc *next;    
  21.  
  22.     int flags;
  23. #define    P_ISTATE    1    /* Process has interrupts enabled */
  24. #define    P_SSET        2    /* Process has set sig */
  25. #define    P_FREEARGS    4    /* Free args on termination */
  26.  
  27.     jmp_buf env;        /* Process state */
  28.     jmp_buf sig;        /* State for alert signal */
  29.     int signo;        /* Arg to alert to cause signal */
  30.     unsigned short state;
  31. #define    READY    0
  32. #define    WAITING    1
  33. #define    SUSPEND    2
  34.     void *event;        /* Wait event */
  35.     int16 *stack;        /* Process stack */
  36.     unsigned stksize;    /* Size of same */
  37.     char *name;        /* Arbitrary user-assigned name */
  38.     int retval;        /* Return value from next pwait() */
  39.     struct timer alarm;    /* Alarm clock timer */
  40.     FILE *input;
  41.     FILE *output;
  42.     int iarg;        /* Copy of iarg */
  43.     void *parg1;        /* Copy of parg1 */
  44.     void *parg2;        /* Copy of parg2 */
  45. };
  46. #define NULLPROC (struct proc *)0
  47. extern struct proc *Waittab[];    /* Head of wait list */
  48. extern struct proc *Rdytab;    /* Head of ready list */
  49. extern struct proc *Curproc;    /* Currently running process */
  50. extern struct proc *Susptab;    /* Suspended processes */
  51. extern int Stkchk;        /* Stack checking flag */
  52.  
  53. struct sigentry {
  54.     void *event;
  55.     int n;
  56. };
  57. struct ksig {
  58.     struct sigentry entry[SIGQSIZE];
  59.     struct sigentry *wp;
  60.     struct sigentry *rp;
  61.     volatile int nentries;    /* modified both by interrupts and main */
  62.     int maxentries;
  63.     int32 dupsigs;
  64.     int lostsigs;
  65.     int32 psigs;        /* Count of psignal calls */
  66.     int32 psigwakes;    /* Processes woken */
  67.     int32 psignops;        /* Psignal calls that didn't wake anything */
  68.     int32 psigsqueued;    /* Psignal calls queued with ints off */
  69.     int32 pwaits;        /* Count of pwait calls */
  70.     int32 pwaitnops;    /* pwait calls that didn't block */
  71.     int32 pwaitints;    /* Pwait calls from interrupt context (error) */
  72. };
  73. extern struct ksig Ksig;
  74.  
  75. /* Prepare for an exception signal and return 0. If after this macro
  76.  * is executed any other process executes alert(pp,val), this will
  77.  * invoke the exception and cause this macro to return a second time,
  78.  * but with the return value 1. This cannot be a function since the stack
  79.  * frame current at the time setjmp is called must still be current
  80.  * at the time the signal is taken. Note use of comma operators to return
  81.  * the value of setjmp as the overall macro expression value.
  82.  */
  83. #define    SETSIG(val)    (Curproc->flags |= P_SSET,\
  84.     Curproc->signo = (val),setjmp(Curproc->sig))
  85.  
  86. /* In  kernel.c: */
  87. void alert __ARGS((struct proc *pp,int val));
  88. void chname __ARGS((struct proc *pp,char *newname));
  89. void killproc __ARGS((struct proc *pp));
  90. void killself __ARGS((void));
  91. struct proc *mainproc __ARGS((char *name));
  92. struct proc *newproc __ARGS((char *name,unsigned int stksize,
  93.     void (*pc) __ARGS((int,void *,void *)),
  94.     int iarg,void *parg1,void *parg2,int freeargs));
  95. void psignal __ARGS((void *event,int n));
  96. int pwait __ARGS((void *event));
  97. void resume __ARGS((struct proc *pp));
  98. int setsig __ARGS((int val));
  99. void suspend __ARGS((struct proc *pp));
  100.  
  101. /* In ksubr.c: */
  102. void chkstk __ARGS((void));
  103. void kinit __ARGS((void));
  104. unsigned phash __ARGS((void *event));
  105. void psetup __ARGS((struct proc *pp,int iarg,void *parg1,void *parg2,
  106.     void  __ARGS(((*pc) __ARGS((int,void *,void *)) )) ));
  107. #ifdef    AMIGA
  108. void init_psetup __ARGS((struct proc *pp));
  109. #endif
  110.  
  111. /* Stack background fill value for high water mark checking */
  112. #define    STACKPAT    0x55aa
  113.  
  114. /* Value stashed in location 0 to detect null pointer dereferences */
  115. #define    NULLPAT        0xdead
  116.  
  117. #endif    /* _PROC_H */
  118.