Search in shivacherukuri.tech@blogger.com

Thursday, March 18, 2010

Fw: pmem.c


-->
#// p mem.c

#include <stdio.h>
#include <errno.h>
#include <sys/pstat.h>

main(argc, argv)
int argc;
char **argv;
{
  struct pst_status pst;
  unsigned int pid;
  unsigned int pages;
  int ret;
  int i;
  for (i=1; i<argc; i++) {
    pid = atoi(argv[i]);
    ret = pstat_getproc(&pst, sizeof(pst), 0, pid);
    if (ret == 1) {
      pages = 0
        + pst.pst_vtsize
        + pst.pst_vdsize
        + pst.pst_vssize
        + pst.pst_vshmsize
        + pst.pst_vmmsize
        + pst.pst_vusize
        + pst.pst_iosize
        ;
      printf("%d: vtsize=%dK\n", pid, 4 * pst.pst_vtsize);
      printf("%d: vdsize=%dK\n", pid, 4 * pst.pst_vdsize);
      printf("%d: vssize=%dK\n", pid, 4 * pst.pst_vssize);
      printf("%d: vshmsize=%dK\n", pid, 4 * pst.pst_vshmsize);
      printf("%d: vmmsize=%dK\n", pid, 4 * pst.pst_vmmsize);
      printf("%d: vusize=%dK\n", pid, 4 * pst.pst_vusize);
      printf("%d: iosize=%dK\n", pid, 4 * pst.pst_iosize);
      printf("%d: %dK\n", pid, 4 * pages);
    }
  }
}

No comments:

Post a Comment