The question pretty much says it all. According to the man page for getrusage(), it returns:
struct timeval ru_utime;
struct timeval ru_stime;
According to the man page, clock_gettime()it returns:
CLOCK_THREAD_CPUTIME_ID (since Linux 2.6.12)
Thread-specific CPU-time clock.
So, how does (stream-specific) "user / system processor usage time" differ from the hourly time of a processor with a specific thread?
Obviously, I ask because I see the difference between the two in the application that I ported to Linux (from user RTOS). This application has an internal profiling function implemented with tick()and functions tock(). Since I was digging into this, I degenerated one part of my application:
tick()
tock()
tick() , , tock() , , , . tick() tock() getrusage(), 0 out, 1000us 10000us ( , 1 100 ). tick() tock() clock_gettime(), 13us ( 75us 100us, ).
VIRT_CPU_ACCOUNTING / VIRT_CPU_ACCOUNTING_GEN. , , , , getrusage(), 1000us 1000.
, , clock_gettime() , , -. , .