]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - lib/libc/sys/thr_wake.2
libc: Fix most issues reported by mandoc
[FreeBSD/FreeBSD.git] / lib / libc / sys / thr_wake.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_WAKE 2
33 .Os
34 .Sh NAME
35 .Nm thr_wake
36 .Nd wake up the suspended thread
37 .Sh LIBRARY
38 .Lb libc
39 .Sh SYNOPSIS
40 .In sys/thr.h
41 .Ft int
42 .Fn thr_wake "long id"
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 Passing the thread identifier of the calling thread
59 .Po
60 see
61 .Xr thr_self 2
62 .Pc
63 to
64 .Fn thr_wake
65 sets a thread's flag to cause the next signal-interruptible sleep
66 of that thread in the kernel to fail immediately with the
67 .Er EINTR
68 error.
69 The flag is cleared by an interruptible sleep attempt or by a call to
70 .Xr thr_suspend 2 .
71 This is used by the system threading library to implement cancellation.
72 .Pp
73 If
74 .Fa id
75 is not equal to the current thread identifier, the specified thread is
76 woken up if suspended by the
77 .Xr thr_suspend 2
78 system call.
79 If the thread is not suspended at the time of the
80 .Nm
81 call, the wake is remembered and the next attempt of the thread to
82 suspend itself with the
83 .Xr thr_suspend 2
84 results in immediate return with success.
85 Only one wake is remembered.
86 .Sh RETURN VALUES
87 .Rv -std thr_wake
88 .Sh ERRORS
89 The
90 .Fn thr_wake
91 operation returns these errors:
92 .Bl -tag -width Er
93 .It Bq Er ESRCH
94 The specified thread was not found or does not belong to the process
95 of the calling thread.
96 .El
97 .Sh SEE ALSO
98 .Xr ps 1 ,
99 .Xr thr_self 2 ,
100 .Xr thr_suspend 2 ,
101 .Xr pthread_cancel 3 ,
102 .Xr pthread_resume_np 3 ,
103 .Xr pthread_suspend_np 3
104 .Sh STANDARDS
105 The
106 .Fn thr_suspend
107 system call is non-standard and is used by
108 .Lb libthr
109 to implement
110 .St -p1003.1-2001
111 .Xr pthread 3
112 functionality.
113 .Sh HISTORY
114 The
115 .Fn thr_suspend
116 system call first appeared in
117 .Fx 5.2 .