maxprecision
maxprecision

Reputation: 1

Converting Jiffies to Microseconds

I want to convert the jiffies time that is extracted from /proc/pid/stat stats, I can convert it to seconds but I am looking for resolution in microseconds or nanoseconds if possible.

I have already looked at Converting jiffies to milli seconds but didn't find it much useful(maybe i did not understand it correctly).

So is it possible to make the conversion in user-space program?

Upvotes: 0

Views: 225

Answers (1)

wkz
wkz

Reputation: 2263

From the man page:

Amount of time that this process has been scheduled in user mode, measured in clock ticks (divide by sysconf(_SC_CLK_TCK))

If you have getconf installed, you can easily test this in your shell:

awk -vhz=$(getconf CLK_TCK) '{
    utime = $14 / hz;
    stime = $15 / hz;

    printf("%s: user:%.3fs sys:%.3fs\n", $2, utime, stime);
}' /proc/1/stat

Upvotes: 1

Related Questions