All of lore.kernel.org
 help / color / mirror / Atom feed
* [Xenomai-help] 0 CPU time problem
@ 2011-11-04 19:08 Tom Z
  2011-11-04 19:21 ` Gilles Chanteperdrix
  0 siblings, 1 reply; 7+ messages in thread
From: Tom Z @ 2011-11-04 19:08 UTC (permalink / raw)
  To: xenomai@xenomai.org

[-- Attachment #1: Type: text/plain, Size: 1387 bytes --]

Hi All,

I am trying to measure the CPU time consumed by a function foo(), and here is how I do it:

void foo(){
        struct timespec tp1, tp2;
        clock_gettime(CLOCK_PROCESS_CPUTIME_ID, &tp);

        //Computation goes here


        clock_gettime(CLOCK_PROCESS_CPUTIME_ID, &tp2);
        //The CPU time is given between the difference between tp2 and tp 1

}


The program is running on Ubuntu 10.10, and the kernel is 2.6.37 patched with Xenomai 2.5.6


Here is what I observed:

1) If foo() is running in the Linux domain (i.e., called by a regular Linux process), the CPU time obtained by the above method looks normal, and the mean CPU time of 25000 invocations of foo() is 10 ms.

2) If foo() is running in the primary domain (i.e., called by a Xenomai task spawned by rt_task_create() and rt_task_start()), then *most of the time*, the CPU time also looks as normal as the result in 1), and the mean CPU time is also about 10 ms. However, I also noticed that sometimes the CPU time obtained by the above method is 0. This zero value did not appear often, and out of 25000 invocations of foo(), I noticed that there is only 1 invocation of foo() where the CPU time is 0. BTW, the Xenomai task's priority is 99.

What causes this 0 CPU time in the primary domain? Is there something wrong with my method to measure the CPU time?

Thanks,
Tom

[-- Attachment #2: Type: text/html, Size: 2167 bytes --]

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2011-11-05 13:33 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-11-04 19:08 [Xenomai-help] 0 CPU time problem Tom Z
2011-11-04 19:21 ` Gilles Chanteperdrix
2011-11-04 21:03   ` Tom Z
2011-11-04 21:36     ` Gilles Chanteperdrix
2011-11-05  2:31       ` Tom Z
2011-11-05 13:33         ` Gilles Chanteperdrix
2011-11-05 11:27       ` Philippe Gerum

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.