Add Book to My BookshelfPurchase This Book Online

Appendix C - The /proc Filesystem

UNIX Systems Programming for SVR4
David A. Curry
 Copyright © 1996 O'Reilly & Associates, Inc.

Obtaining Process Resource Usage
The PIOCUSAGE code obtains the process' resource usage information and stores it in a structure of type prusage_t:
typedef struct prusage {
  id_t              pr_lwpid;       /* lwp id.  0: process or defunct     */
  u_long            pr_count;       /* number of contributing lwps        */
  timestruc_t         pr_tstamp;    /* current time stamp                 */
  timestruc_t         pr_create;    /* process/lwp creation time stamp    */
  timestruc_t         pr_term;      /* process/lwp termination time stamp */
  timestruc_t         pr_rtime;     /* total lwp real (elapsed) time      */
  timestruc_t         pr_utime;     /* user level CPU time                */
  timestruc_t         pr_stime;     /* system call CPU time               */
  timestruc_t         pr_ttime;     /* other system trap CPU time         */
  timestruc_t         pr_tftime;    /* text page fault sleep time         */
  timestruc_t         pr_dftime;    /* data page fault sleep time         */
  timestruc_t         pr_kftime;    /* kernel page fault sleep time       */
  timestruc_t         pr_ltime;     /* user lock wait sleep time          */
  timestruc_t         pr_slptime;   /* all other sleep time               */
  timestruc_t         pr_wtime;     /* wait-cpu (latency) time            */
  timestruc_t         pr_stoptime;  /* stopped time                       */
  timestruc_t         filltime[6];  /* filler for future expansion        */
  u_long            pr_minf;        /* minor page faults                  */
  u_long            pr_majf;        /* major page faults                  */
  u_long            pr_nswap;       /* swaps                              */
  u_long            pr_inblk;       /* input blocks                       */
  u_long            pr_oublk;       /* output blocks                      */
  u_long            pr_msnd;        /* messages sent                      */
  u_long            pr_mrcv;        /* messages received                  */
  u_long            pr_sigs;        /* signals received                   */
  u_long            pr_vctx;        /* voluntary context switches         */
  u_long            pr_ictx;        /* involuntary context switches       */
  u_long            pr_sysc;        /* system calls                       */
  u_long            pr_ioch;        /* chars read and written             */
  u_long            filler[10];     /* filler for future expansion        */
} prusage_t;
Some of the more interesting fields of this structure are:
pr_rtime
The elapsed time since the process was created.
pr_utime
The amount of user time used by the process.
pr_stime
The amount of time spent by the process in system calls.
pr_slptime
The amount of time the process has spent sleeping.
pr_stoptime
The amount of time the process has spent in the stopped state.
pr_minf
The number of minor page faults incurred by the process.
A minor page fault is one that can be serviced without any I/O activity by reclaiming the page from the list of pages awaiting reallocation.
pr_majf
The number of major page faults incurred by the process.
A major page fault is one that requires I/O activity to service.
pr_nswap
The number of times the process has been swapped out of main memory.
pr_inblk
The number of blocks input for the process by the filesystem.
pr_oublk
The number of blocks output for the process by the filesystem.
pr_sigs
The number of signals received by the process.
pr_sysc
The number of system calls made by the process.
pr_ioch
The number of characters input and output by the process to terminal-like devices.

Previous SectionNext Section
Books24x7.com, Inc © 2000 –  Feedback