Why I can't get the seconds and nanoseconds like this?
Nicholas Mc Guire
der.herr at hofr.at
Mon Jan 8 06:49:37 CET 2007
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
> Hi:
> I wrote the simple application like this.
>
> #include <stdio.h>
> #include <l4/util/rdtsc.h>
> #include <l4/sys/l4int.h>
> #include <l4/thread/thread.h>
>
> char LOG_tag[4]="clk";
>
> int main(void)
> {
> l4_uint32_t *second;
> l4_uint32_t *nanosecond;
> l4_cpu_time_t tsc;
> tsc = l4_rdtsc();
> l4_tsc_to_s_and_ns(tsc, second, nanosecond);
> printf("%d, %d \n", *second, *nanosecond);
> }
>
> The result is :
> clk | 0, 0
> clk |
> clk | Exiting with 6
>
> Does these code have some problems?
> Thank you.
> cheng
did you ever initialize the tsc scallare ? it depends on your
configuration - it is not necessarily done automatically - you could check
if thats the problem first by simply printing the tsc value it self (as 64
bit value) and if that is non-0 (as to be expected) then the
initialization is most likely the problem. to initialized the scalar you
use:
l4_uint32_t l4_tsc_init (int constraint)
Initialize the scalers needed by l4_tsc_to_ns()/l4_ns_to_tsc() and CPU ticks
see:
http://os.inf.tu-dresden.de/l4env/doc/html/l4util/group__rdtsc.html#ga8
for a bit more details
other than that I don't see a prblem
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.4 (GNU/Linux)
iD8DBQFFodtynU7rXZKfY2oRAokUAJ9ukIHPaIQci3U4q1td+7CgUUszBACfX0AD
KWPgZ/0S4BqKQmOFW7nimHY=
=zyCv
-----END PGP SIGNATURE-----
More information about the l4-hackers
mailing list