time problem
Michael Roitzsch
mroi at os.inf.tu-dresden.de
Tue May 19 11:05:12 CEST 2009
Hi,
> these days I try to use another way to test the time used by the
> operation:
> I use l4_rdtsc() function,but after I using it as following:
>
> #include <l4/util/rdtsc.h>
> ...
> ...
> l4_cpu_time_t tsc1,tsc2;
> l4_uint32_t args;
> ...
> ...
> tsc1 = l4_rdtsc();
> ...
> /*operations*/
> ...
> tsc2 = l4_rdtsc();
> args = l4_tsc_to_us(tsc2 - tsc1);
> printf("start_tsc = %ld\n end_tsc = %ld\n us_time =
> %u",tsc1,tsc2,args);
>
> why can't I test the time?
> for example,one result is:
> tsc1 = -2036300143
> tsc2 = 1
> us_time = 3129796927
There's two things at work here: First, you have to call
l4_calibrate_tsc() once before using the conversion functions from tsc
to wallclock time like l4_tsc_to_us(). Second, l4_cpu_time_t is 64 Bit
wide, so you cannot printf it with %ld as the format string. You
should use %lld there.
Michael
More information about the l4-hackers
mailing list