How to get RTC tick under user mode?

F

frakie

Hi 'body, is there any function to get the RTC ticks under user mode
on linux?
I could not use gettimeofday because it is too slow and affects
measures...
 
W

Walter Roberson

Hi 'body, is there any function to get the RTC ticks under user mode
on linux?
I could not use gettimeofday because it is too slow and affects
measures...

There is no way to do that using only the facilities provided
by the C language itself. You will need to use system-specific
extensions. Please consult a linux programming newsgroup (and it might
be in a linux programming FAQ somewhere.)
 
C

Charlie Gordon

Walter Roberson said:
There is no way to do that using only the facilities provided
by the C language itself. You will need to use system-specific
extensions. Please consult a linux programming newsgroup (and it might
be in a linux programming FAQ somewhere.)

Google for: RDTSC linux
 
F

frakie

Google for: RDTSC linux

Thanks this is really useful!


extern __inline__ unsigned long long int rdtsc()
{
long long int x;
__asm__ volatile (".byte 0x0f, 0x31" : "=A" (x));
return x;
}

By now I have to find a divisor to transform it in microseconds.. :)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,432
Messages
2,571,681
Members
48,796
Latest member
Greg L.

Latest Threads

Top