]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - lib/libc/sys/thr_suspend.2
libc: Fix most issues reported by mandoc
[FreeBSD/FreeBSD.git] / lib / libc / sys / thr_suspend.2
1 .\" Copyright (c) 2016 The FreeBSD Foundation, Inc.
2 .\" All rights reserved.
3 .\"
4 .\" This documentation was written by
5 .\" Konstantin Belousov <kib@FreeBSD.org> under sponsorship
6 .\" from the FreeBSD Foundation.
7 .\"
8 .\" Redistribution and use in source and binary forms, with or without
9 .\" modification, are permitted provided that the following conditions
10 .\" are met:
11 .\" 1. Redistributions of source code must retain the above copyright
12 .\"    notice, this list of conditions and the following disclaimer.
13 .\" 2. Redistributions in binary form must reproduce the above copyright
14 .\"    notice, this list of conditions and the following disclaimer in the
15 .\"    documentation and/or other materials provided with the distribution.
16 .\"
17 .\" THIS SOFTWARE IS PROVIDED BY THE AUTHORS AND CONTRIBUTORS ``AS IS'' AND
18 .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19 .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20 .\" ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE
21 .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22 .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
23 .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
24 .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25 .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27 .\" SUCH DAMAGE.
28 .\"
29 .\" $FreeBSD$
30 .\"
31 .Dd May 5, 2020
32 .Dt THR_SUSPEND 2
33 .Os
34 .Sh NAME
35 .Nm thr_suspend
36 .Nd suspend the calling thread
37 .Sh LIBRARY
38 .Lb libc
39 .Sh SYNOPSIS
40 .In sys/thr.h
41 .Ft int
42 .Fn thr_suspend "struct timespec *timeout"
43 .Sh DESCRIPTION
44 .Bf -symbolic
45 This function is intended for implementing threading.
46 Normal applications should use
47 .Xr pthread_cond_timedwait 3
48 together with
49 .Xr pthread_cond_broadcast 3
50 for typical safe suspension with cooperation of the thread
51 being suspended, or
52 .Xr pthread_suspend_np 3
53 and
54 .Xr pthread_resume_np 3
55 in some specific situations, instead.
56 .Ef
57 .Pp
58 The
59 .Fn thr_suspend
60 system call puts the calling thread in a suspended state, where it is
61 not eligible for CPU time.
62 This state is exited by another thread calling
63 .Xr thr_wake 2 ,
64 when the time interval specified by
65 .Fa timeout
66 has elapsed,
67 or by the delivery of a signal to the suspended thread.
68 .Pp
69 If the
70 .Fa timeout
71 argument is
72 .Dv NULL ,
73 the suspended state can be only terminated by explicit
74 .Fn thr_wake
75 or signal.
76 .Pp
77 If a wake from
78 .Xr thr_wake 2
79 was delivered before the
80 .Nm
81 call, the thread is not put into a suspended state.
82 Instead, the call
83 returns immediately without an error.
84 .Pp
85 If a thread previously called
86 .Xr thr_wake 2
87 with its own thread identifier, which resulted in setting the internal kernel
88 flag to immediately abort interruptible sleeps with an
89 .Er EINTR
90 error
91 .Po
92 see
93 .Xr thr_wake 2
94 .Pc ,
95 the flag is cleared.
96 As with
97 .Xr thr_wake 2
98 called from another thread, the next
99 .Nm
100 call does not result in suspension.
101 .Sh RETURN VALUES
102 .Rv -std thr_suspend
103 .Sh ERRORS
104 The
105 .Fn thr_suspend
106 operation returns the following errors:
107 .Bl -tag -width Er
108 .It Bq Er EFAULT
109 The memory pointed to by the
110 .Fa timeout
111 argument is not valid.
112 .It Bq Er ETIMEDOUT
113 The specified timeout expired.
114 .It Bq Er ETIMEDOUT
115 The
116 .Fa timeout
117 argument specified a zero time interval.
118 .It Bq Er EINTR
119 The sleep was interrupted by a signal.
120 .El
121 .Sh SEE ALSO
122 .Xr ps 1 ,
123 .Xr thr_wake 2 ,
124 .Xr pthread_resume_np 3 ,
125 .Xr pthread_suspend_np 3
126 .Sh STANDARDS
127 The
128 .Fn thr_suspend
129 system call is non-standard.
130 .Sh HISTORY
131 The
132 .Fn thr_suspend
133 system call first appeared in
134 .Fx 5.2 .