home *** CD-ROM | disk | FTP | other *** search
- Nntp-Posting-Host: alaska.et.byu.edu
- Lines: 48
- Path: sparky!uunet!nevada.edu!news.unomaha.edu!news.mtholyoke.edu!news.byu.edu!news
- Message-ID: <`}#@byu.edu>
- Date: Tue, 10 Nov 92 08:40:17 MST
- From: gritton@alaska.et.byu.edu (Jamie Gritton)
- Organization: Brigham Young University, Provo UT USA
- Newsgroups: comp.sys.hp
- Subject: Re: How to use pstat() in HP-UX 8.0x?
- Reply-To: gritton@byu.edu
- References: <1dmqteINNa7n@manuel.anu.edu.au>
- Distribution: world
-
- I've played around with pstat() a bit, and while I may not have found
- out all there is to find, here's what I know:
-
-
-
- There are three structures used by the call, pst_status,
- pst_static, and pst_dynamic. You call it different ways to get
- different information.
-
- The static and dynamic structures contain information about the
- kernel and the machine. As their names imply, the static structure
- contains information that won't change at least until reboot or
- reconfiguration, and the dynamic structure contains information that
- constantly changes. Look in the include file for specific fields. Of
- particular interest is the max_proc field in the static structure.
-
- The call to get this information is:
-
- struct pst_static pstatic;
- pstat( PSTAT_STATIC, &pstatic, sizeof pstatic, 0, 0);
-
- The pst_status structure, as mentioned in the header file, can be
- called two ways; you can get information about a certain process, or
- all processes. The information returned is everything that you ever
- wanted to know about the process. To get a single process:
-
- struct pst_status pstatus;
- int pid;
- pstat( PSTAT_PROC, &pstatus, sizeof pstatus, 0, pid)
-
- To get part of the process table:
-
- struct pst_status pst[NPROC];
- int index, nproc;
- nproc = pstat( PSTAT_PROC, pst, sizeof *pst, NPROC, index);
-
- This will get entries of the process table from index to
- index+NPROC-1, or less if you go past the currest size of the table. I
- think (I may be wrong -- it's been a while) that the table has PIDs in
- numerical order. The call will return the actual number of pst_status
- structures written into the array. To get the full process table, use:
-
- struct pst_status *pst;
- int index, nproc;
- pst = malloc( pstatic.max_proc * sizeof *pst);
- nproc = pstat( PSTAT_PROC, pst, sizeof *pst, pstatic.max_proc, index);
- --
- James Gritton - gritton@byu.edu - I disclaim
-