USLEEP(3) Library Functions Manual USLEEP(3)NAME
usleep - suspend execution for interval
The current process is suspended from execution for the number of microseconds specified by the argument. The actual suspension time may
be an arbitrary amount longer because of other activity in the system or because of the time spent in processing the call.
The routine is implemented by setting an interval timer and pausing until it occurs. The previous state of this timer is saved and
restored. If the sleep time exceeds the time to the expiration of the previous timer, the process sleeps only until the signal would have
occurred, and the signal is sent a short time later.
This routine is implemented using setitimer(2); it requires eight system calls each time it is invoked. A similar but less compatible
function can be obtained with a single select(2); it would not restart after signals, but would not interfere with other uses of setitimer.
SEE ALSO setitimer(2), getitimer(2), sigpause(2), ualarm(3), sleep(3), alarm(3)NOTES (PDP-11)
On the PDP-11, setitimer(2) rounds the number of microseconds up to seconds resolution, therefore usleep doesn't give you any more resolu-
tion than sleep(3). Select(2) offers clock resolution (usually 60Hz in the U.S.A. and 50Hz elsewhere) and so should be used instead.
4.3 Berkeley Distribution August 26, 1988 USLEEP(3)
Check Out this Related Man Page
USLEEP(3) BSD Library Functions Manual USLEEP(3)NAME
usleep -- suspend thread execution for an interval measured in microseconds
Standard C Library (libc, -lc)
The usleep() function suspends execution of the calling thread until either useconds microseconds have elapsed or a signal is delivered to
the thread whose action is to invoke a signal-catching function or to terminate the thread or process. The actual time slept may be longer,
due to system latencies and possible limitations in the timer resolution of the hardware.
This function is implemented, using nanosleep(2), by pausing for useconds microseconds or until a signal occurs. Consequently, in this
implementation, sleeping has no effect on the state of process timers and there is no special handling for SIGALRM.
The usleep() function returns the value 0 if successful; otherwise the value -1 is returned and the global variable errno is set to indicate
The usleep() function will fail if:
[EINTR] A signal was delivered to the process and its action was to invoke a signal-catching function.
SEE ALSO nanosleep(2), sleep(3)HISTORY
The usleep() function appeared in 4.3BSD.
BSD February 13, 1998 BSD
I set a timer using setitimer to expire every 30 ms.
Usually it does. But sometimes it takes ~ 700 ms between 2 successive arousals (expirations). The timing is crucial for me.
The process with the timer is almost the only one running on the computer.
How do I overcome this problem? (1 Reply)
I need usleep command to use in one of my shell script. I am working on SunOS 5.9. Where usleep command is not available. Is there any way to use usleep command in SunOS.
Thanks In Advance,
chidhu (5 Replies)
How can I use floating point argument for sleep command in unix.I cannot use usleep as it is not suppported.
Also how can I find out that a file is in use at that particular instant only.(wether it is being read or written) (7 Replies)
In the process of restoring a few DEC PDP-11/34's (34a, and 34). Curious what BSD versions will run on the 34 (if any).
It looks like 1BSD or 2BSD might run on it, but not sure. Curious if anyone knows, or has done this. (1 Reply)
I have 2 files that print on the same line at the same time. I wanted to add time.sleep() to 1 of the textfiles. I wanted to delay the time that 1 textfile prints with the other 1 in this script. I wanted to have the files to create new lines instead of printing the same combinations when they both... (5 Replies)