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