PSTAT Interfaces

12
Example:
#include <stdlib.h>
#include <errno.h>
#include <sys/pstat.h>
void main(void)
{
int i;
int rv;
struct pst_dynamic psd;
struct pst_lvinfo *pstlv;
size_t NumOpenLV = 20;
pstlv = (struct pst_lvinfo *)
malloc(NumOpenLV * sizeof(struct pst_lvinfo));
if (pstlv == (struct pst_lvinfo *) 0) {
fprintf(stderr, "iomon: memory allocation failure\n");
exit(1);
}
if ((rv = pstat_getlv(pstlv, sizeof(struct pst_lvinfo), NumOpenLV, 0))
== -1) {
printf("pstat_getlv() returned -1\n");
printf("Error code = %d\n", errno);
exit(1);
}
for (i = 0; i < rv; i++) {
printf("%3d --> Major = %d; Minor = 0x%06x; Reads = %lu\n",
i, (int) pstlv[i].psl_dev.psd_major,
(int) pstlv[i].psl_dev.psd_minor,
(int) pstlv[i].psl_rxfer);
}
}
4.10 pstat_getlwp()
Synopsis:
int pstat_getlwp(struct lwp_status *buf, size_t elemsize, size_t elemcount, int index, pid_t pid);
Description:
This call returns information about the threads or LWPs (Lightweight Processes) in a
process. There is one instance of this context for each LWP in a process on the system. For each
instance requested, data up to a maximum of elemsize bytes are returned in the struct lwp_status
pointed to by buf. The elemcount parameter specifies the number of structs lwp_status that are
available at buf. The index parameter specifies the starting index within the context of LWPs in a
process.
If pid is set to -1 and elemcount is greater than 0, elemcount entries of system LWP
information are returned to the caller program. If pid is greater than or equal to 0 and elemcount
is greater than 0, elemcount entries of LWP info within the process specified by pid are returned.
As a shortcut, information about a single LWP can be obtained by setting elemcount to zero and
setting index to the TID (Thread ID) of that LWP within its process.
Return Value:
This call returns –1 on failure or number of instances copied to buf on success.
Errors:
EINVAL is set if the following conditions are not met.