> Gary -- use the "rdtsc" instruction which stands for read
> timestamp counter. This instruction will return the number of cycles the
> processor has been up since it was last rebooted. It is 64 bits so the
> processor will turn to slag before it overflows.
>
> Below is the inline assembly language that will compile under gcc.
>
> __inline__ unsigned long long int rdtsc()
> {
> unsigned long long int x;
> __asm__ volatile (".byte 0x0f, 0x31" : "=A" (x));
> return x;
> }
>
Hi !
same code just a bit more human redable...to check the jitter of a system -
note that the jitter reported is a theorectical one as it is the delay that
can be introced between any two calls on a non-rt system. compile it and run
it on a idle box - if you let it run long enough you will see 1s maximum !
if you load the box heavaly (pingflood , multiple ls -lR / , compile kernel
with make -j 60 ...) you will find half second jumps happening quite soon.
(just ran it on a PIII/800). You also might want to look at the gethrtime
function in rtlinux (rtlinux-3.X/schedulers/i386/rtl_time.h)
---non_rt_jitt.c---
#include <stdio.h>
#include <asm/io.h>
// this is the "ugly" solution
__inline__ unsigned long long int rdtsc(void)
{
unsigned long long int x;
__asm__ volatile (".byte 0x0f, 0x31" : "=A" (x));
return x;
}
// this is the "beautifull" solution
__inline__ unsigned long long int hwtime(void)
{
unsigned long long int x;
__asm__("rdtsc\n\t"
"mov %%edx, %%ecx\n\t"
:"=A" (x));
return x;
}
main(){
long long int hwtime1,hwtime2,jitt,jitt_max;
jitt_max=0;
while(1){
hwtime1 = hwtime();
hwtime2 = hwtime();
jitt=hwtime2-hwtime1;
if(jitt > jitt_max){
jitt_max=jitt;
printf("got %lx\n",jitt);
}
sleep(1);
}
return;
}
-- [rtl] ---
To unsubscribe:
echo "unsubscribe rtl" | mail [EMAIL PROTECTED] OR
echo "unsubscribe rtl <Your_email>" | mail [EMAIL PROTECTED]
--
For more information on Real-Time Linux see:
http://www.rtlinux.org/