xref: /netbsd-src/share/man/man9/kpause.9 (revision 8b0f9554ff8762542c4defc4f70e1eb76fb508fa)
1.\"	$NetBSD: kpause.9,v 1.2 2007/10/28 21:33:23 rjs Exp $
2.\"
3.\" Copyright (c) 2006, 2007 The NetBSD Foundation, Inc.
4.\" All rights reserved.
5.\"
6.\" This code is derived from software contributed to The NetBSD Foundation
7.\" by Andrew Doran.
8.\"
9.\" Redistribution and use in source and binary forms, with or without
10.\" modification, are permitted provided that the following conditions
11.\" are met:
12.\" 1. Redistributions of source code must retain the above copyright
13.\"    notice, this list of conditions and the following disclaimer.
14.\" 2. Redistributions in binary form must reproduce the above copyright
15.\"    notice, this list of conditions and the following disclaimer in the
16.\"    documentation and/or other materials provided with the distribution.
17.\" 3. All advertising materials mentioning features or use of this software
18.\"    must display the following acknowledgement:
19.\"        This product includes software developed by the NetBSD
20.\"        Foundation, Inc. and its contributors.
21.\" 4. Neither the name of The NetBSD Foundation nor the names of its
22.\"    contributors may be used to endorse or promote products derived
23.\"    from this software without specific prior written permission.
24.\"
25.\" THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
26.\" ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
27.\" TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
28.\" PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
29.\" BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
30.\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
31.\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
32.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
33.\" CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
34.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
35.\" POSSIBILITY OF SUCH DAMAGE.
36.\"
37.\" ------------------------------------------------------------
38.Dd July 18, 2007
39.Dt KPAUSE 9
40.Os
41.\" ------------------------------------------------------------
42.Sh NAME
43.Nm kpause
44.Nd make the calling LWP sleep
45.\" ------------------------------------------------------------
46.Sh SYNOPSIS
47.In sys/proc.h
48.\" - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
49.Ft int
50.Fn kpause \
51"const char *wmesg" "bool intr" "int timeo" "kmutex_t *mtx"
52.\" ------------------------------------------------------------
53.Sh DESCRIPTION
54.Fn kpause
55makes the calling LWP sleep.
56It's similar to
57.Xr cv_timedwait_sig 9
58without the corresponding
59.Xr cv_signal 9 .
60.Pp
61.Fn kpause
62can wake up spontaneously.
63Callers should prepare to handle it.
64.Pp
65.Bl -tag -width wmesg
66.It Fa wmesg
67Specifies a string of no more than 8 characters that describes
68the resource or condition associated with the call of
69.Fn kpause .
70The kernel does not use this argument directly but makes it available for
71utilities such as
72.Xr ps 1
73to display.
74.It Fa intr
75If true, sleep interruptably.
76If the LWP recieves a signal, or is interrupted by another condition such
77as its containing process exiting, the wait is ended early and an error
78code returned.
79.It Fa timeo
80Specify a timeout.
81It is an architecture and system dependent value related to the number of
82clock interrupts per second.
83See
84.Xr hz 9
85for details.
86The
87.Xr mstohz 9
88macro can be used to convert a timeout expressed in milliseconds to
89one suitable for
90.Fn kpause .
91.Pp
92Zero means no timeout.
93.It Fa mtx
94Specifies a kernel mutex to be used as an interlock, and must be held by the
95calling LWP on entry to
96.Fn kpause .
97It will be released once the LWP has prepared to sleep, and will be reacquired
98before
99.Fn kpause
100returns.
101.Fn kpause
102will release it before sleeping and acquire before returning.
103.El
104.\" ------------------------------------------------------------
105.Sh RETURN VALUES
106.Fn kpause
107returns 0 when waking up spontaneously.
108Otherwise,
109It returns an error number.
110.\" ------------------------------------------------------------
111.Sh ERRORS
112.Bl -tag -width Er
113.It Bq Er EWOULDBLOCK
114The timeout expired.
115.It Bq Er ERESTART
116.Fn kpause
117returned as a result of a signal with
118.Dv SA_RESTART
119property.
120.It Bq Er EINTR
121.Fn kpause
122returned due to other reasons.
123Typically as a result of a signal without
124.Dv SA_RESTART
125property.
126.El
127.\" ------------------------------------------------------------
128.Sh SEE ALSO
129.Xr sigaction 2 ,
130.Xr errno 9 ,
131.Xr condvar 9 ,
132.Xr mstohz 9 ,
133.Xr hz 9
134