Dear all, Please allow me to post this newbie question that must have been answered many times before. I have my doubts about the actual resolution of CPU TIME USAGE MEASUREMENT for individual tasks, that is using the clock_gettime() with the thread clock id. From one side, it looks as the counter of cpu-time use in each thread is done with a jiffy resolution: - utime and stime fields in task_struct seem to be unsigned long, therefore in 32bit archs they cannot have a very high resolution. http://lxr.linux.no/#linux+v3.6.3/kernel/posix-cpu-timers.c http://lxr.linux.no/linux+*/include/linux/sched.h#L1362 http://lxr.linux.no/linux+*/include/asm-generic/cputime.h#L7 - utime and stime fields in /proc/<tid>/stat come out in jiffies according to proc man page. since I guess that these utime and stime fields are the basis of the cpuclock implementation I infer that the effective resolution of thread or process usage is limited by the jiffy resolution (4msg with CONFIG_HZ=250) of the utime and stime fields in task_struct. On the other side, clock_getres() returns 1 nanosec and the well known hrtimers merge in 2.6.21 announced highly and broadly that the jiffy barrier has been lifted with real time clocks and timers. So my questions are: * What is the effective resolution of two invocations of clock_gettime() on the same running thread for a long period involving several CPU preemptions? * Are there other fields apart from stime and utime with the sufficient precision to maintain a CPU usage count? * Does the PREEMPT_RT branch improve this resolution somehow? Thanks in advance for your time. Cheers, Miguel Telleria -- (O-O) ---oOO-(_)-OOo----------------------------------------------------- Miguel TELLERIA DE ESTEBAN http://www.mtelleria.com Email: miguel at mtelleria.com Tel GSM: +34 650 801098 Tel Fix: +34 942 280174 Miembro de http://www.linuca.org Membre du http://www.bxlug.be ¿Usuario captivo o libre? http://www.obtengalinux.org/windows/ Free or captive user? http://www.getgnulinux.org/windows/ -------------------------------------------------------------------
Attachment:
signature.asc
Description: PGP signature