home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 January / usenetsourcesnewsgroupsinfomagicjanuary1994.iso / sources / unix / volume3 / sps / part2 / sps.h < prev    next >
Encoding:
C/C++ Source or Header  |  1986-11-30  |  6.3 KB  |  150 lines

  1. # include       <h/param.h>
  2. # include       <h/dir.h>
  3. # include       <h/user.h>
  4. # include       <h/proc.h>
  5.  
  6. /*
  7. ** Maximum # of users to be considered. (Should probably be
  8. ** approximately double the # of users in /etc/passwd.)
  9. */
  10. # define        MAXUSERID       100
  11. /* Maximum # ttys to be considered ... */
  12. # define        MAXTTYS         60
  13. /* Maximum user name length ... */
  14. # define        UNAMELEN        8
  15. /* Maximum process-id not to be considered busy ... */
  16. # define        MSPID           2
  17. /* # of wait states defined in the `struct info' ... */
  18. # define        NWAITSTATE      36
  19.  
  20. /* Convert clicks to kbytes ... */
  21. # ifdef SUN
  22. # define        KBYTES( size )  ((size) << 1)
  23. # else
  24. # define        KBYTES( size )  ((size) >> (10 - PGSHIFT))
  25. # endif
  26.  
  27. /* Standard files to be examined ... */
  28. # define        FILE_MEM        "/dev/mem"      /* System physical memory */
  29. # define        FILE_KMEM       "/dev/kmem"     /* Kernel virtual memory */
  30. # define        FILE_SWAP       "/dev/drum"     /* Swap/paging device */
  31. # define        FILE_DEV        "/dev"          /* Directory of tty entries */
  32. # define        FILE_SYMBOL     "/vmunix"       /* Symbol file for nlist() */
  33. # define        FILE_INFO       "/etc/spsinfo"  /* Sps information file */
  34.  
  35. /* Structure to hold necessary information concerning a tty ... */
  36. struct ttyline
  37. {
  38.     struct tty              *l_addr ;       /* Ptr to tty struct in kmem */
  39.     unsigned short          l_pgrp ;        /* Tty process group */
  40.     char                    l_name[2] ;     /* Tty character name */
  41.     dev_t                   l_dev ;         /* Tty device # */
  42. } ;
  43.  
  44. /* Structure holding a single hash table entry ... */
  45. struct hashtab
  46. {
  47.     unsigned short          h_uid ;         /* Uid of user entry */
  48.     char                    h_uname[ UNAMELEN ] ; /* Corresponding name */
  49. } ;
  50.  
  51. /*
  52. ** Format of the standard information file maintained by sps.
  53. ** This structure is filled in at initialisation time and then is read back
  54. ** in whenever sps is invoked.
  55. ** Note that the pointer variables in this structure refer to
  56. ** kernel virtual addresses, not addresses within sps.
  57. ** These variable are typed as such so that pointer arithmetic
  58. ** on the kernel addresses will work correctly.
  59. */
  60. struct info
  61. {       /* Kernel values determining process, tty and upage info ... */
  62.     struct proc             *i_proc0 ;      /* address of process table */
  63.     int                     i_nproc ;       /* length of process table */
  64.     struct text             *i_text0 ;      /* address of text table */
  65.     int                     i_ntext ;       /* length of text table */
  66.     struct inode            *i_inode0 ;     /* address of inode table */
  67.     int                     i_ninode ;      /* length of inode table */
  68.     struct buf              *i_swbuf0 ;     /* address of swap buffers */
  69.     int                     i_nswbuf ;      /* # swap buffers */
  70.     struct buf              *i_buf0 ;       /* address of i/o buffers */
  71.     int                     i_nbuf ;        /* # i/o buffers */
  72.     int                     i_ecmx ;        /* max physical memory address*/
  73.     struct pte              *i_usrptmap ;   /* page table map */
  74.     struct pte              *i_usrpt ;      /* page table map */
  75.     struct cdevsw           *i_cdevsw ;     /* device switch to find ttys */
  76. # ifdef BSD42
  77.     struct quota            *i_quota0 ;     /* disc quota structures */
  78.     int                     i_nquota ;      /* # quota structures */
  79.     int                     i_dmmin ;       /* The start of the disc map */
  80.     int                     i_dmmax ;       /* The end of the disc map */
  81.     struct mbuf             *i_mbutl ;      /* Start of mbuf area */
  82. # else
  83.     int                     i_hz ;          /* Clock rate */
  84. # endif
  85. # ifdef CHAOS
  86.     caddr_t                 i_Chconntab ;   /* Chaos connection table */
  87. # endif
  88.     /* Kernel addresses are associated with process wait states ... */
  89.     caddr_t                 i_waitstate[ NWAITSTATE ] ;
  90.     /* User names, stored in a hash table ... */
  91.     struct hashtab          i_hnames[ MAXUSERID ] ;
  92.     /* Tty device info ... */
  93.     struct ttyline          i_ttyline[ MAXTTYS ] ;
  94. } ;
  95.  
  96. /*
  97. ** The symbol structure cross-references values read from the kernel with
  98. ** their place in the info structure, and if such a value is associated with
  99. ** a process wait state or not.
  100. */
  101. struct symbol
  102. {
  103.     char                    *s_kname ;      /* Kernel symbol name */
  104.     char                    s_indirect ;    /* Value requires indirection */
  105.     caddr_t                 *s_info ;       /* Corresponding info address */
  106.     char                    *s_wait ;       /* Reason for wait, if any */
  107. } ;
  108.  
  109. /* The `user' structure obtained from /dev/mem or /dev/swap ... */
  110. union userstate
  111. {
  112.     struct user             u_us ;
  113.     char                    u_pg[ UPAGES ][ NBPG ] ;
  114. } ;
  115.  
  116. /* Information concerning each process filled from /dev/kmem ... */
  117. struct process
  118. {
  119.     struct proc             pr_p ;          /* struct proc from /dev/kmem */
  120.     struct process          *pr_plink ;     /* Normalised ptrs from above */
  121.     struct process          *pr_sibling ;   /* Ptr to sibling process */
  122.     struct process          *pr_child ;     /* Ptr to child process */
  123.     struct process          *pr_pptr ;      /* Ptr to parent process */
  124. # ifdef BSD42
  125.     struct rusage           pr_rself ;      /* Read from upage for self */
  126.     struct rusage           pr_rchild ;     /* ... and the children */
  127. # else
  128.     struct vtimes           pr_vself ;      /* Read from upage for self */
  129.     struct vtimes           pr_vchild ;     /* ... and the children */
  130. # endif
  131.     int                     pr_files ;      /* # open files */
  132.     struct ttyline          *pr_tty ;       /* Associated tty information */
  133.     char                    *pr_cmd ;       /* Command args, from upage */
  134.     int                     pr_upag:1 ;     /* Upage was obtained */
  135.     int                     pr_csaved:1 ;   /* Cmd args saved by malloc() */
  136. } ;
  137.  
  138. /* Structure to hold summarising information ... */
  139. struct summary
  140. {
  141.     long                    sm_ntotal ;     /* Total # processes */
  142.     long                    sm_ktotal ;     /* Total virtual memory */
  143.     long                    sm_nbusy ;      /* # busy processes */
  144.     long                    sm_kbusy ;      /* Busy virtual memory */
  145.     long                    sm_nloaded ;    /* # loaded processes */
  146.     long                    sm_kloaded ;    /* Active resident memory */
  147.     long                    sm_nswapped ;   /* # swapped processes */
  148.     long                    sm_kswapped ;   /* Size totally swapped out */
  149. } ;
  150.