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
-----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
On Mon Jan 08, 2007 at 06:49:37 +0100, Nicholas Mc Guire wrote:
-----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);
Don't do this, where are those pointers pointing to? You need to allocate some memory to put the data in:
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:
Usually l4_calibrate_tsc() is what's used.
Adam
l4-hackers@os.inf.tu-dresden.de