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