This is my understanding (someone correct me if I am wrong):
If you really want to go to "sleep", the smallest amount you can delay
is one clock tick, assuming nothing else is running. On the Intel
platform, that is 10 mS.
You can use select() to get uS timing. I've never really eveluated the
precision of this, but the following function does use select() that
way:
int delay_us(int microseconds)
{
struct timeval tv;
if( microseconds >= 1000000 )
{
tv.tv_sec = microseconds % 1000000;
tv.tv_usec = microseconds / 1000000;
}
else
{
tv.tv_sec = 0;
tv.tv_usec = microseconds;
}
select (0,0,0,0,&tv); /* block 'til timeout */
return 0;
}
I'm guessing that when select blocks, you lose your timeslice. Can
anyone tell me what this is really doing. (The program I needed this
for works, so I've never spent any more time on it).
-- Robert Wuest, PE Empowered Kemet Electronics Sirius Engineering Company by robertwuest@kemet.com mailto:rwuest@sire.vt.com Linux