Hi

I have a program that sleeps in user space for 10 seconds
and im' tryin gto verify that the sleep is actually 10 seconds
so I did something like this
time1 = rtdsc();
sleep( seconds);
time2 = rtdsc();

but i'm not sure what to do from this point forward... since the numbers returned are HUGE and the difference isn't 10

I have to test the same thing in the kernel space but I was warned not to try sleep(); in the kernel

any suggestions, advice etc
Thanks

ras

Hey There,

I found this out on the web if you really want to use rtdsc to measure clock cycles, but you can also just use the time function:

time()

and subtract the begin time from the end time for an accurate measurement without getting into too much nitty-gritty

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

Hope that helps :)

, Mike

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.