186 lines
7.7 KiB
HTML
186 lines
7.7 KiB
HTML
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
|
|
<html>
|
|
<head>
|
|
<meta name="generator" content="HTML Tidy, see www.w3.org">
|
|
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
|
|
<link type="text/css" rel="stylesheet" href="style.css"><!-- Generated by The Open Group's rhtm tool v1.2.1 -->
|
|
<!-- Copyright (c) 2001 The Open Group, All Rights Reserved -->
|
|
<title>usleep</title>
|
|
</head>
|
|
<body bgcolor="white">
|
|
<script type="text/javascript" language="JavaScript" src="../jscript/codes.js">
|
|
</script>
|
|
|
|
<basefont size="3"> <a name="usleep"></a> <a name="tag_03_805"></a><!-- usleep -->
|
|
<!--header start-->
|
|
<center><font size="2">The Open Group Base Specifications Issue 6<br>
|
|
IEEE Std 1003.1-2001<br>
|
|
Copyright © 2001 The IEEE and The Open Group, All Rights reserved.</font></center>
|
|
|
|
<!--header end-->
|
|
<hr size="2" noshade>
|
|
<h4><a name="tag_03_805_01"></a>NAME</h4>
|
|
|
|
<blockquote>usleep - suspend execution for an interval</blockquote>
|
|
|
|
<h4><a name="tag_03_805_02"></a>SYNOPSIS</h4>
|
|
|
|
<blockquote class="synopsis">
|
|
<div class="box"><code><tt><sup>[<a href="javascript:open_code('OB XSI')">OB XSI</a>]</sup> <img src="../images/opt-start.gif" alt=
|
|
"[Option Start]" border="0"> #include <<a href="../basedefs/unistd.h.html">unistd.h</a>><br>
|
|
<br>
|
|
int usleep(useconds_t</tt> <i>useconds</i><tt>); <img src="../images/opt-end.gif" alt="[Option End]" border="0"></tt></code></div>
|
|
|
|
<tt><br>
|
|
</tt></blockquote>
|
|
|
|
<h4><a name="tag_03_805_03"></a>DESCRIPTION</h4>
|
|
|
|
<blockquote>
|
|
<p>The <i>usleep</i>() function shall cause the calling thread to be suspended from execution until either the number of realtime
|
|
microseconds specified by the argument <i>useconds</i> has elapsed or a signal is delivered to the calling thread and its action is
|
|
to invoke a signal-catching function or to terminate the process. The suspension time may be longer than requested due to the
|
|
scheduling of other activity by the system.</p>
|
|
|
|
<p>The <i>useconds</i> argument shall be less than one million. If the value of <i>useconds</i> is 0, then the call has no
|
|
effect.</p>
|
|
|
|
<p>If a SIGALRM signal is generated for the calling process during execution of <i>usleep</i>() and if the SIGALRM signal is being
|
|
ignored or blocked from delivery, it is unspecified whether <i>usleep</i>() returns when the SIGALRM signal is scheduled. If the
|
|
signal is being blocked, it is also unspecified whether it remains pending after <i>usleep</i>() returns or it is discarded.</p>
|
|
|
|
<p>If a SIGALRM signal is generated for the calling process during execution of <i>usleep</i>(), except as a result of a prior call
|
|
to <a href="../functions/alarm.html"><i>alarm</i>()</a>, and if the SIGALRM signal is not being ignored or blocked from delivery,
|
|
it is unspecified whether that signal has any effect other than causing <i>usleep</i>() to return.</p>
|
|
|
|
<p>If a signal-catching function interrupts <i>usleep</i>() and examines or changes either the time a SIGALRM is scheduled to be
|
|
generated, the action associated with the SIGALRM signal, or whether the SIGALRM signal is blocked from delivery, the results are
|
|
unspecified.</p>
|
|
|
|
<p>If a signal-catching function interrupts <i>usleep</i>() and calls <a href=
|
|
"../functions/siglongjmp.html"><i>siglongjmp</i>()</a> or <a href="../functions/longjmp.html"><i>longjmp</i>()</a> to restore an
|
|
environment saved prior to the <i>usleep</i>() call, the action associated with the SIGALRM signal and the time at which a SIGALRM
|
|
signal is scheduled to be generated are unspecified. It is also unspecified whether the SIGALRM signal is blocked, unless the
|
|
process' signal mask is restored as part of the environment.</p>
|
|
|
|
<p>Implementations may place limitations on the granularity of timer values. For each interval timer, if the requested timer value
|
|
requires a finer granularity than the implementation supports, the actual timer value shall be rounded up to the next supported
|
|
value.</p>
|
|
|
|
<p>Interactions between <i>usleep</i>() and any of the following are unspecified:</p>
|
|
|
|
<blockquote>
|
|
<pre>
|
|
<a href="../functions/nanosleep.html"><i>nanosleep</i>()</a>
|
|
<a href="../functions/setitimer.html"><i>setitimer</i>()</a>
|
|
<a href="../functions/timer_create.html"><i>timer_create</i>()</a>
|
|
<a href="../functions/timer_delete.html"><i>timer_delete</i>()</a>
|
|
<a href="../functions/timer_getoverrun.html"><i>timer_getoverrun</i>()</a>
|
|
<a href="../functions/timer_gettime.html"><i>timer_gettime</i>()</a>
|
|
<a href="../functions/timer_settime.html"><i>timer_settime</i>()</a>
|
|
<a href="../functions/ualarm.html"><i>ualarm</i>()</a>
|
|
<a href="../functions/sleep.html"><i>sleep</i>()</a>
|
|
</pre>
|
|
</blockquote>
|
|
</blockquote>
|
|
|
|
<h4><a name="tag_03_805_04"></a>RETURN VALUE</h4>
|
|
|
|
<blockquote>
|
|
<p>Upon successful completion, <i>usleep</i>() shall return 0; otherwise, it shall return -1 and set <i>errno</i> to indicate the
|
|
error.</p>
|
|
</blockquote>
|
|
|
|
<h4><a name="tag_03_805_05"></a>ERRORS</h4>
|
|
|
|
<blockquote>
|
|
<p>The <i>usleep</i>() function may fail if:</p>
|
|
|
|
<dl compact>
|
|
<dt>[EINVAL]</dt>
|
|
|
|
<dd>The time interval specified one million or more microseconds.</dd>
|
|
</dl>
|
|
</blockquote>
|
|
|
|
<hr>
|
|
<div class="box"><em>The following sections are informative.</em></div>
|
|
|
|
<h4><a name="tag_03_805_06"></a>EXAMPLES</h4>
|
|
|
|
<blockquote>
|
|
<p>None.</p>
|
|
</blockquote>
|
|
|
|
<h4><a name="tag_03_805_07"></a>APPLICATION USAGE</h4>
|
|
|
|
<blockquote>
|
|
<p>Applications are recommended to use <a href="../functions/nanosleep.html"><i>nanosleep</i>()</a> if the Timers option is
|
|
supported, or <a href="../functions/setitimer.html"><i>setitimer</i>()</a>, <a href=
|
|
"../functions/timer_create.html"><i>timer_create</i>()</a>, <a href="../functions/timer_delete.html"><i>timer_delete</i>()</a>, <a
|
|
href="../functions/timer_getoverrun.html"><i>timer_getoverrun</i>()</a>, <a href=
|
|
"../functions/timer_gettime.html"><i>timer_gettime</i>()</a>, or <a href=
|
|
"../functions/timer_settime.html"><i>timer_settime</i>()</a> instead of this function.</p>
|
|
</blockquote>
|
|
|
|
<h4><a name="tag_03_805_08"></a>RATIONALE</h4>
|
|
|
|
<blockquote>
|
|
<p>None.</p>
|
|
</blockquote>
|
|
|
|
<h4><a name="tag_03_805_09"></a>FUTURE DIRECTIONS</h4>
|
|
|
|
<blockquote>
|
|
<p>None.</p>
|
|
</blockquote>
|
|
|
|
<h4><a name="tag_03_805_10"></a>SEE ALSO</h4>
|
|
|
|
<blockquote>
|
|
<p><a href="alarm.html"><i>alarm</i>()</a> , <a href="getitimer.html"><i>getitimer</i>()</a> , <a href=
|
|
"nanosleep.html"><i>nanosleep</i>()</a> , <a href="sigaction.html"><i>sigaction</i>()</a> , <a href="sleep.html"><i>sleep</i>()</a>
|
|
, <a href="timer_create.html"><i>timer_create</i>()</a> , <a href="timer_delete.html"><i>timer_delete</i>()</a> , <a href=
|
|
"timer_getoverrun.html"><i>timer_getoverrun</i>()</a> , the Base Definitions volume of IEEE Std 1003.1-2001, <a href=
|
|
"../basedefs/unistd.h.html"><i><unistd.h></i></a></p>
|
|
</blockquote>
|
|
|
|
<h4><a name="tag_03_805_11"></a>CHANGE HISTORY</h4>
|
|
|
|
<blockquote>
|
|
<p>First released in Issue 4, Version 2.</p>
|
|
</blockquote>
|
|
|
|
<h4><a name="tag_03_805_12"></a>Issue 5</h4>
|
|
|
|
<blockquote>
|
|
<p>Moved from X/OPEN UNIX extension to BASE.</p>
|
|
|
|
<p>The DESCRIPTION is changed to indicate that timers are now thread-based rather than process-based.</p>
|
|
</blockquote>
|
|
|
|
<h4><a name="tag_03_805_13"></a>Issue 6</h4>
|
|
|
|
<blockquote>
|
|
<p>The DESCRIPTION is updated to avoid use of the term "must" for application requirements.</p>
|
|
|
|
<p>This function is marked obsolescent.</p>
|
|
</blockquote>
|
|
|
|
<div class="box"><em>End of informative text.</em></div>
|
|
|
|
<hr>
|
|
<hr size="2" noshade>
|
|
<center><font size="2"><!--footer start-->
|
|
UNIX ® is a registered Trademark of The Open Group.<br>
|
|
POSIX ® is a registered Trademark of The IEEE.<br>
|
|
[ <a href="../mindex.html">Main Index</a> | <a href="../basedefs/contents.html">XBD</a> | <a href=
|
|
"../utilities/contents.html">XCU</a> | <a href="../functions/contents.html">XSH</a> | <a href="../xrat/contents.html">XRAT</a>
|
|
]</font></center>
|
|
|
|
<!--footer end-->
|
|
<hr size="2" noshade>
|
|
</body>
|
|
</html>
|
|
|