]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - lib/libc/sys/thr_wake.2
zfs: merge openzfs/zfs@a0b2a93c4
[FreeBSD/FreeBSD.git] / lib / libc / sys / thr_wake.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 .Dd May 5, 2020
29 .Dt THR_WAKE 2
30 .Os
31 .Sh NAME
32 .Nm thr_wake
33 .Nd wake up the suspended thread
34 .Sh LIBRARY
35 .Lb libc
36 .Sh SYNOPSIS
37 .In sys/thr.h
38 .Ft int
39 .Fn thr_wake "long id"
40 .Sh DESCRIPTION
41 .Bf -symbolic
42 This function is intended for implementing threading.
43 Normal applications should use
44 .Xr pthread_cond_timedwait 3
45 together with
46 .Xr pthread_cond_broadcast 3
47 for typical safe suspension with cooperation of the thread
48 being suspended, or
49 .Xr pthread_suspend_np 3
50 and
51 .Xr pthread_resume_np 3
52 in some specific situations, instead.
53 .Ef
54 .Pp
55 Passing the thread identifier of the calling thread
56 .Po
57 see
58 .Xr thr_self 2
59 .Pc
60 to
61 .Fn thr_wake
62 sets a thread's flag to cause the next signal-interruptible sleep
63 of that thread in the kernel to fail immediately with the
64 .Er EINTR
65 error.
66 The flag is cleared by an interruptible sleep attempt or by a call to
67 .Xr thr_suspend 2 .
68 This is used by the system threading library to implement cancellation.
69 .Pp
70 If
71 .Fa id
72 is not equal to the current thread identifier, the specified thread is
73 woken up if suspended by the
74 .Xr thr_suspend 2
75 system call.
76 If the thread is not suspended at the time of the
77 .Nm
78 call, the wake is remembered and the next attempt of the thread to
79 suspend itself with the
80 .Xr thr_suspend 2
81 results in immediate return with success.
82 Only one wake is remembered.
83 .Sh RETURN VALUES
84 .Rv -std thr_wake
85 .Sh ERRORS
86 The
87 .Fn thr_wake
88 operation returns these errors:
89 .Bl -tag -width Er
90 .It Bq Er ESRCH
91 The specified thread was not found or does not belong to the process
92 of the calling thread.
93 .El
94 .Sh SEE ALSO
95 .Xr ps 1 ,
96 .Xr thr_self 2 ,
97 .Xr thr_suspend 2 ,
98 .Xr pthread_cancel 3 ,
99 .Xr pthread_resume_np 3 ,
100 .Xr pthread_suspend_np 3
101 .Sh STANDARDS
102 The
103 .Fn thr_suspend
104 system call is non-standard and is used by
105 .Lb libthr
106 to implement
107 .St -p1003.1-2001
108 .Xr pthread 3
109 functionality.
110 .Sh HISTORY
111 The
112 .Fn thr_suspend
113 system call first appeared in
114 .Fx 5.2 .