home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #26 / NN_1992_26.iso / spool / comp / sys / hp / 12739 < prev    next >
Encoding:
Text File  |  1992-11-10  |  2.3 KB  |  62 lines

  1. Nntp-Posting-Host: alaska.et.byu.edu
  2. Lines: 48
  3. Path: sparky!uunet!nevada.edu!news.unomaha.edu!news.mtholyoke.edu!news.byu.edu!news
  4. Message-ID: <`}#@byu.edu>
  5. Date: Tue, 10 Nov 92 08:40:17 MST
  6. From: gritton@alaska.et.byu.edu (Jamie Gritton)
  7. Organization: Brigham Young University, Provo UT USA
  8. Newsgroups: comp.sys.hp
  9. Subject: Re: How to use pstat() in HP-UX 8.0x?
  10. Reply-To: gritton@byu.edu
  11. References: <1dmqteINNa7n@manuel.anu.edu.au>
  12. Distribution: world
  13.  
  14.    I've played around with pstat() a bit, and while I may not have found
  15. out all there is to find, here's what I know:
  16.  
  17.  
  18.  
  19.    There are three structures used by the call, pst_status,
  20. pst_static, and pst_dynamic. You call it different ways to get
  21. different information.
  22.  
  23.    The static and dynamic structures contain information about the
  24. kernel and the machine. As their names imply, the static structure
  25. contains information that won't change at least until reboot or
  26. reconfiguration, and the dynamic structure contains information that
  27. constantly changes. Look in the include file for specific fields. Of
  28. particular interest is the max_proc field in the static structure.
  29.  
  30.    The call to get this information is:
  31.  
  32. struct pst_static pstatic;
  33. pstat( PSTAT_STATIC, &pstatic, sizeof pstatic, 0, 0);
  34.  
  35.    The pst_status structure, as mentioned in the header file, can be
  36. called two ways; you can get information about a certain process, or
  37. all processes. The information returned is everything that you ever
  38. wanted to know about the process. To get a single process:
  39.  
  40. struct pst_status pstatus;
  41. int pid;
  42. pstat( PSTAT_PROC, &pstatus, sizeof pstatus, 0, pid)
  43.  
  44.    To get part of the process table:
  45.  
  46. struct pst_status pst[NPROC];
  47. int index, nproc;
  48. nproc = pstat( PSTAT_PROC, pst, sizeof *pst, NPROC, index);
  49.  
  50.    This will get entries of the process table from index to
  51. index+NPROC-1, or less if you go past the currest size of the table. I
  52. think (I may be wrong -- it's been a while) that the table has PIDs in
  53. numerical order. The call will return the actual number of pst_status
  54. structures written into the array. To get the full process table, use:
  55.  
  56. struct pst_status *pst;
  57. int index, nproc;
  58. pst = malloc( pstatic.max_proc * sizeof *pst);
  59. nproc = pstat( PSTAT_PROC, pst, sizeof *pst, pstatic.max_proc, index);
  60. --
  61. James Gritton - gritton@byu.edu - I disclaim
  62.