SUMMARY: Need millisecond sleep() subroutine

From: Don Catey (
Date: Thu Aug 01 1996 - 11:12:45 CDT

Thanks to everyone that replied (far too many to list). I appreciate your

The overwhelming vote is for usleep, which will allow sleeping in micro-
seconds. There were also suggestions for nanosleep, poll (NULL, 0, n)
and the following select routine from Gregory Bond:

struct tv stime = {0, 500000}; /* 500 ms */

select(0, 0, 0, 0, &stime);

And there was also this from Ernst-Gunar Ortlepp:
#include <sys/param.h>
#include <sys/types.h>
#include <sys/time.h>

int value;
        fd_set *A=NULL,*B=NULL,*C=NULL;
        struct timeval tt;
        tt.tv_sec = 0;
        tt.tv_usec = value;

Then there is this from Trevor Paquette:
/* sleeps for the specified time. */

#include <signal.h>
#include <sys/time.h>

#define ITIMER_REAL 0

long seconds, micro_seconds;
 int do_nothing();
 struct itimerval new_value, old_value;

 /* set time for timeout */
 new_value.it_value.tv_sec = seconds;
 new_value.it_value.tv_usec = micro_seconds;
 /* and don't reload it when it times out */
 new_value.it_interval.tv_sec = 0;
 new_value.it_interval.tv_usec = 0;

 /*catch the signal*/

 /* start the timer */

 /* wait for the signal */

 /*restore any old values */

do_nothing ()

Original Message:

> Does anyone know of a C sleep subroutine that will give delays in
> milliseconds instead of seconds or any increment less than a second?

Best Regards!!!

Don Catey Internet:
Systems Administrator Compuserve:

--------Information Technology Solutions and Support----------

Motorola, Inc. Voice: 602/675-2608
Space & Systems Fax: 602/441-7138
    Technology Group
8201 East McDowell Road Any views, thoughts, or opinions
M/S H1192 expressed are my own, and are in
Scottsdale, AZ 85257 no way those of Motorola, Inc.

This archive was generated by hypermail 2.1.2 : Fri Sep 28 2001 - 23:11:06 CDT