Subj : Re: nptl threads execution time To : comp.programming.threads From : loic-dev Date : Wed Apr 13 2005 03:25 am Hallo Christian, > > Perhaps I don't understand your question correctly, but wouldn't the > > function clock_gettime() with a CLOCK_THREAD_CPUTIME_ID clock do it? > > This function measures the time a thread has been scheduled on a > > processor. > > In my tests on several systems the function clock_gettime() with > CLOCK_THREAD_CPUTIME_ID doesn't return the cputime of a thread, but the > cputime of the whole process. The function clock_gettime() with a CLOCK_THREAD_CPUTIME_ID exists for some time now on Linux, but is really fully functionnal only since recently. You need the newest glibc and 2.6.x kernel... On FC3, tests reveal that the cputime of a thread is returned as expected. > The sole chance to get the cputime of a thread is to parse the > file /proc//task//stat. > This works under linux. Correct, albeit not portable... > But under AIX 5.1 I didn't find a solution. Actually, if your system doesn't comply to SuSv3, there are no portable solution to this problem. Though Pthreads implementation based on 1:1 model should have some relatively straightforward way to give you that information. However, you need a hook to the kernel to get that info (which is given by the /proc under Linux). Loic. .