2010/8/12 prakash srinivasan <[email protected]>
>
> Deal All,
> I am executing a simple for() loop and like to calculate the time period for 
> this loop. I used rt_timer_read(). As per the document, it mentioned that 
> rt_timer_read() returns the current time expressed in clock ticks. I could 
> not able to get an clear idea about it. Suppose if i convert it by using 
> rt_timer_ticks2ns(), I am not getting the proper output. My code is,
>
> RTIME start, end;
> ...
> ...
> start=rt_timer_read();
> for()
> {}
> end=rt_timer_read();
> printf(TOTAL LOOP TIMING=%ld usn", 
> (long)((rt_timer_ticks2ns(end-start))/1000);
>
> I would like to convert the ticks into nano seconds first and then into micro 
> seconds. The final result is irrelevant. I am not sure, where is the issue. 
> Help me to find the timings details properly.

Irrelevant how? Not repeatable?
What are the printed values?

Did you try without rt_timer_ticks2ns first?

Did you see the note on rt_timer_read() ?
http://www.xenomai.org/documentation/xenomai-2.5/html/api/group__native__timer.html#g9665d6947e29d1a19dafb5401b0f6285
Note:
    The value returned will represent a count of jiffies if the native
skin is bound to a periodic time base (see
CONFIG_XENO_OPT_NATIVE_PERIOD), or nanoseconds otherwise.

> In the example program trivial-periodic.c, they mentioned
>
> "NOTE: printf may have unexpected impact on the timing of your program. It is 
> used here in the critical loop only for demonstration purposes."
> Why?

Because printf is a complicated function ending up with syscalls which
would make you switch to secondar mode etc.... (you can search the ML
for answers on this subject).

Note that in your case the printf is after the loop (and timer read) so this
must not be the problem.

--
Erk
Membre de l'April - « promouvoir et défendre le logiciel libre » -
http://www.april.org

_______________________________________________
Xenomai-help mailing list
[email protected]
https://mail.gna.org/listinfo/xenomai-help

Reply via email to