why nanosleep sleeps less than the specified time interval !?

Alex kbyte at iol.pt
Fri Dec 23 16:14:59 UTC 2005


Hello all,

I am using the nanosleep primitive to sleep for 100000000 nanoseconds. 
I am using the rdtsc pentium instruction to verify the sleep time of the nanosleep.

Env: pentium celeron mendocino 400MHZ

...
tv.tv_sec=0;
tv.tv_nsec=100000000;
...
Get ticks using rdtsc 
result=nanosleep(&tv, &tr);
Get ticks using rdtsc
subtract ticks
...

I was expected to measure about 40000000 ticks or more but never less than 40000000.

There is measurements where the rdtsc counts only 36723810 ticks (91,80 miliseconds).
As I am using the rdtsc one expects to get more than 40000000 ticks and never less due to the overhead of the 
rdtsc instruction. But I get 36723810 ticks which is less than 40000000.

Is this a good behaviour?

As the 8253 chip ticks every 0.055 seconds there is no granularity problems, right?

So why this behaviour?

I searched for the macros US_TO_TICK and TICK_TO_US (bsp.h) and I saw undocumented magic numbers there. :-(

Ex: 

#define US_TO_TICK(us) (((us)*105+44)/88

Why 105?   why 44? why 88?

Why not use official tick rate of the 8253 chip to program it?  (0.055 seconds period)


Can someone help me understanding this behaviour?


Many thanks

Marry Christmas and a happy new year.

Alex

_______________________________________________________________________________________
100% GRATIS - AMEN.PT - Dominio .be - Ferramenta de criacao de sites, alojamento, anti-virus/spam...
Saber mais em http://www.iol.pt/correio/rodape.php?dst=0512201





More information about the users mailing list