1 .\" $NetBSD: nanosleep.2,v 1.23 2016/11/14 10:40:59 wiz Exp $
3 .\" Copyright (c) 1986, 1991, 1993
4 .\" The Regents of the University of California. All rights reserved.
6 .\" Redistribution and use in source and binary forms, with or without
7 .\" modification, are permitted provided that the following conditions
9 .\" 1. Redistributions of source code must retain the above copyright
10 .\" notice, this list of conditions and the following disclaimer.
11 .\" 2. Redistributions in binary form must reproduce the above copyright
12 .\" notice, this list of conditions and the following disclaimer in the
13 .\" documentation and/or other materials provided with the distribution.
14 .\" 3. Neither the name of the University nor the names of its contributors
15 .\" may be used to endorse or promote products derived from this software
16 .\" without specific prior written permission.
18 .\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
19 .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20 .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21 .\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
22 .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
23 .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
24 .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
25 .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
26 .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
27 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
30 .\" @(#)sleep.3 8.1 (Berkeley) 6/4/93
38 .Nd high resolution sleep
45 .Fa "clockid_t clock_id"
47 .Fa "const struct timespec *rqtp"
48 .Fa "struct timespec *rmtp"
52 .Fa "const struct timespec *rqtp"
53 .Fa "struct timespec *rmtp"
58 flag is not set in the
62 suspends execution of the calling thread until either the
63 time interval specified by the
66 or a signal is delivered to the calling process and its
67 action is to invoke a signal-catching function or to terminate the
69 The clock used to measure the time is specified by the
79 suspends execution of the calling thread until either the value
80 of the clock specified by the
82 argument reaches the absolute time specified by the
85 or a signal is delivered to the calling process and its
86 action is to invoke a signal-catching function or to terminate the
88 If, at the time of the call, the time value specified by
90 is less than or equal to the time value of the specified clock, then
92 returns immediately and the calling thread is not suspended.
94 The suspension time may be longer than requested due to the
95 scheduling of other activity by the system.
96 It is also subject to the allowed time interval deviation
98 .Va kern.timecounter.alloweddeviation
101 An unmasked signal will terminate the sleep early, regardless of the
103 value on the interrupting signal.
108 arguments can point to the same object.
112 values are supported:
114 .Bl -item -compact -offset indent
120 CLOCK_MONOTONIC_PRECISE
126 CLOCK_REALTIME_PRECISE
139 function behaves like
151 These functions return zero when the requested time has elapsed.
153 If these functions return for any other reason, then
155 will directly return the error number, and
157 will return \-1 with the global variable
159 set to indicate the error.
160 If a relative sleep is interrupted by a signal and
164 the timespec structure it references is updated to contain the
165 unslept amount (the request time minus the time actually slept).
167 These functions can fail with the following errors.
174 points to memory that is not a valid part of the process
177 The function was interrupted by the delivery of a signal.
181 argument specified a nanosecond value less than zero
182 or greater than or equal to 1000 million.
186 argument contained an invalid flag.
191 .Dv CLOCK_THREAD_CPUTIME_ID
192 or an unrecognized value.
196 argument was valid but not supported by this implementation of
197 .Fn clock_nanosleep .
200 .Xr clock_gettime 2 ,
204 These functions conform to