Declaration:int getrusage (int who, struct rusage *usage);
The Getrusage function returns the current resource usage. Returns the resource usage for the current process when the WHO parameter is rusage_self, and returns the resource used by the child process with a status of terminating or waiting when it is rusage_children.
The returned result exists in struct struct rusage:
struct Rusage { struct timeval ru_utime;/* User Time used the duration of use */ struct timeval ru_stime;/* System " D The time of the kernel usage */ long ru_maxrss; /* Maximum resident set size */ long ru_ixrss; /* Integral shared memory size */ long ru_idrss; /* Integral unshared data size */ long ru_isrss; /* Integral unshared stack size */ long Ru_minflt; /* Page reclaims */ long Ru_majflt; /* Page faults */ long ru_nswap; /* Swaps */ long ru_inblock; /* Block INPUT operations */ long ru_oublock; /* Block OUTPUT operations */ long ru_msgsnd; /* Messages sent */ long RU_MSGRCV; /* Messages received */ long ru_nsignals; /* Signals received */ long RU_NVCSW; /* Voluntary Context Switches */ long RU_NIVCSW; /* Involuntary Context switches */};
Use of Getrusage in Linux