Visit Our UNIX and Linux User Community

Linux and UNIX Man Pages

Test Your Knowledge in Computers #591
Difficulty: Medium
Selection Sort and Insertion Sort are simple but very efficient search algorithms.
True or False?
Linux & Unix Commands - Search Man Pages

usleep(3) [bsd man page]

USLEEP(3)						     Library Functions Manual							 USLEEP(3)

usleep - suspend execution for interval SYNOPSIS
usleep(useconds) unsigned useconds; DESCRIPTION
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)

usleep -- suspend thread execution for an interval measured in microseconds LIBRARY
Standard C Library (libc, -lc) SYNOPSIS
#include <unistd.h> int usleep(useconds_t useconds); DESCRIPTION
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. RETURN VALUES
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 error. ERRORS
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

6 More Discussions You Might Find Interesting

1. AIX

how to implement timer

anyone can help me how to implement the timer on AIX? I tried with 'setitimer' and its related functions, but it does not work correctly,the program exited each time. thanks (2 Replies)
Discussion started by: Frank2004
2 Replies

2. Programming

setitimer expires in wrong time

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)
Discussion started by: inna
1 Replies

3. Solaris

usleep command is not available in SunOS

Hi All, 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)
Discussion started by: pa.chidhambaram
5 Replies

4. UNIX for Advanced & Expert Users

Floating point argument for sleep command in Unix

Hi , 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)
Discussion started by: kanus
7 Replies

5. BSD

BSD for PDP-11/34a?

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)
Discussion started by: xenix
1 Replies

6. UNIX for Beginners Questions & Answers

Adder timer to 1 of these columns

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)
Discussion started by: bigvito19
5 Replies

Featured Tech Videos