Hi I am running into a little issue while working on a project for my OS class. I am instructed to use getrusage() to determine the amount of time spent in both user modes and kernel modes for a program I am writing. The issue is that it always tells me my CPU and kernel usage is zero. When looking up the function the man page mentions that if some of the members of the rusage struct are not supported by your particular version of linux they are just set to ZERO. Basically I was wondering if someone could tell me if my calling of the function and accessing its parameters is correct(so I can tell whether or not I am the issue or those features are not supported by my kernel).
Code
struct rusage usage;
struct rusage *p = &usage;
getrusage(RUSAGE_SELF, p);
printf("time in user mode = %ld\ntime in kernel mode = %ld\n", p->ru_utime.tv_sec, p->ru_stime.tv_sec);