High-resolution user/system times?

High-resolution user/system times?

Nadav Har'El nyh at math.technion.ac.il
Wed Jul 25 11:07:26 IDT 2012


On Wed, Jul 25, 2012, Nadav Har'El wrote about "High-resolution user/system times?":
> I'm now trying to measure a process running around 3 milliseconds, less
> than one jiffy, and I still want to understand how much of it is spent in
> user space, and how much of it is spent in kernel space (e.g., handling on

Thanks for all the ideas.
I think I found an even simpler solution:

It appears that while times(2) has a 4-ms resolution, it doesn't mean
that every time a 3-ms process is measured it returns 0. Rather, it
seems probabilistic - the user-space count seems (but I didn't verify in
the code...) to return 0 if the timer interrupt happened while the code
was in the kernel or 1 if the code was in user space.
So what I can do is to run the whole process 1,000 times, and add up the
"1" and "0"s which I get for system time, and if I get for example 30,
I know that the process was in the kernel for 30/1000 of the time.

I no idea how accurate this will be, but it might just work, and is
very simple...

-- 
Nadav Har'El                        |        Wednesday, Jul 25 2012, 6 Av 5772
nyh at math.technion.ac.il             |-----------------------------------------
Phone +972-523-790466, ICQ 13349191 |Wear short sleeves! Support your right to
http://nadav.harel.org.il           |bare arms!



More information about the Linux-il mailing list