Mail Archives: djgpp/1998/12/18/15:10:56
On 18 Dec 1998, ADAM SCHROTENBOER wrote:
) If you want to release the time slice, write your own sleep function.
Okay...
) >I was expecting the program to sleep quietly for 5 secs and then
) >continue
) >the while();
#include <time.h>
int mysleep(int seconds) {
struct timeval tv;
tv.tv_sec = seconds;
tv.tv_usec = 0;
select(0, NULL, NULL, NULL, &tv);
return(tv.tv_sec);
}
That should emulate sleep() pretty well. If the mysleep() call is
interrupted during the select(), it'll return the number of seconds
remaining in the sleep timeout, just like the standard sleep() does.
--
Daniel Reed <n AT ml DOT org>
I'll never forget the first time I ran Windows, but I'm trying...
- Raw text -