xref: /freebsd/share/man/man3/pthread_np.3 (revision 3e5d0784b9b5296bda801add034b057ad68237f7)
1.\" Copyright (c) 2021 Felix Johnson <felix.the.red@gmail.com>
2.\"
3.\" Redistribution and use in source and binary forms, with or without
4.\" modification, are permitted provided that the following conditions
5.\" are met:
6.\" 1. Redistributions of source code must retain the above copyright
7.\"    notice, this list of conditions and the following disclaimer.
8.\" 2. Redistributions in binary form must reproduce the above copyright
9.\"    notice, this list of conditions and the following disclaimer in the
10.\"    documentation and/or other materials provided with the distribution.
11.\"
12.\" THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
13.\" ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
14.\" LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
15.\" PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
16.\" HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
17.\" SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
18.\" LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
19.\" DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
20.\" THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
21.\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
22.\" OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
23.\"
24.Dd October 12, 2021
25.Dt PTHREAD_NP 3
26.Os
27.Sh NAME
28.Nm pthread_np
29.Nd FreeBSD extensions to POSIX thread functions
30.Sh LIBRARY
31.Lb libpthread
32.Sh SYNOPSIS
33.In pthread_np.h
34.Sh DESCRIPTION
35This manual page documents extensions to the POSIX thread functions.
36These extensions may or may not be portable to other operating systems.
37.Pp
38The POSIX thread functions are summarized in this section in the following
39groups:
40.Pp
41.Bl -bullet -offset indent -compact
42.It
43Thread Routines
44.It
45Attribute Object Routines
46.It
47Mutex Routines
48.El
49.\" .It
50.\" Condition Variable Routines
51.\" .It
52.\" Read/Write Lock Routines
53.\" .It
54.\" Per-Thread Context Routines
55.\" .It
56.\" Cleanup Routines
57.Ss Thread Routines
58.Bl -tag -width indent
59.It Xo
60.Ft int
61.Fo pthread_getaffinity_np
62.Fa "pthread_t td" "size_t cpusetsize" "cpuset_t *cpusetp"
63.Fc
64.Xc
65Get the CPU affinity of a specified thread.
66.It Xo
67.Ft int
68.Fn pthread_get_name_np "pthread_t thread" "char *name" "size_t len"
69.Xc
70Get the name of a specified thread.
71.It Xo
72.Ft int
73.Fn pthread_getname_np "pthread_t thread" "char *name" "size_t len"
74.Xc
75Get the name of a specified thread.
76.It Xo
77.Ft int
78.Fn pthread_getthreadid_np void
79.Xc
80Get the calling thread's integral ID.
81.It Xo
82.Ft int
83.Fn pthread_main_np void
84.Xc
85Identify the initial thread.
86.It Xo
87.Ft int
88.Fn pthread_multi_np void
89.Xc
90Sets the thread's scheduling mode to multi-threaded.
91.It Xo
92.Ft int
93.Fn pthread_peekjoin_np "pthread_t thread" "void **value_ptr"
94.Xc
95Peek into the exit status of a specified thread.
96.It Xo
97.Ft int
98.Fn pthread_resume_all_np void
99.Xc
100Resume all suspended threads.
101.It Xo
102.Ft int
103.Fo pthread_setaffinity_np
104.Fa "pthread_t td" "size_t cpusetsize" "const cpuset_t *cpusetp"
105.Fc
106.Xc
107Set the CPU affinity of a specified thread.
108.It Xo
109.Ft int
110.Fn pthread_set_name_np "pthread_t thread" "char *name"
111.Xc
112Sets the specified thread's name.
113.It Xo
114.Ft int
115.Fn pthread_setname_np "pthread_t thread" "char *name"
116.Xc
117Sets the specified thread's name.
118.It Xo
119.Ft int
120.Fn pthread_single_np void
121.Xc
122Sets the thread's scheduling mode to single-threaded.
123.It Xo
124.Ft int
125.Fn pthread_suspend_np "pthread_t tid"
126.Xc
127Suspend the specified thread.
128.It Xo
129.Ft int
130.Fn pthread_suspend_all_np void
131.Xc
132Suspend all active threads.
133.It Xo
134.Ft int
135.Fn pthread_switch_add_np "pthread_switch_routine_t routine"
136.Xc
137Install a routine that is called every time a thread context switches.
138.It Xo
139.Ft int
140.Fn pthread_switch_delete_np "pthread_switch_routine_t routine"
141.Xc
142Remove a routine that is called every time a thread context switches.
143.It Xo
144.Ft int
145.Fo pthread_timedjoin_np
146.Fa "pthread_t thread" "void **value_ptr" "const struct timespec *abstime"
147.Fc
148.Xc
149A variant of
150.Fn pthread_join
151with a timeout.
152.El
153.Ss Attribute Object Routines
154.Bl -tag -width indent
155.It Xo
156.Ft int
157.Fo pthread_attr_get_np
158.Fa "pthread_t pid" "pthread_attr_t *dst"
159.Fc
160.Xc
161Get the attributes of an existent thread.
162.It Xo
163.Ft int
164.Fo pthread_attr_getaffinity_np
165.Fa "const pthread_attr_t *pattr" "size_t cpusetsize" "cpuset_t *cpusetp"
166.Fc
167.Xc
168Get the CPU affinity mask from the thread attribute object.
169.It Xo
170.Ft int
171.Fo pthread_attr_setaffinity_np
172.Fa "pthread_attr_t *pattr" "size_t cpusetsize" "const cpuset_t *cpusetp"
173.Fc
174.Xc
175Set the CPU affinity mask for the thread attribute object.
176.It Xo
177.Ft int
178.Fn pthread_attr_setcreatesuspend_np "pthread_attr_t *attr"
179.Xc
180Permit creation of suspended threads.
181.El
182.Ss Mutex Routines
183.Bl -tag -width indent
184.It Xo
185.Ft int
186.Fn pthread_mutexattr_getkind_np "pthread_mutexattr_t attr"
187.Xc
188Deprecated, use
189.Xr pthread_mutexattr_gettype 3
190instead.
191.It Xo
192.Ft int
193.Fn pthread_mutexattr_setkind_np "pthread_mutexattr_t *attr"
194.Xc
195Deprecated, use
196.Xr pthread_mutexattr_settype 3
197instead.
198.El
199.\" .Ss Condition Variable Routines
200.\" .Bl -tag -width indent
201.\" .El
202.\" .Ss Read/Write Lock Routines
203.\" .Bl -tag -width indent
204.\" .El
205.\" .Ss Per-Thread Context Routines
206.\" .Bl -tag -width indent
207.\" .El
208.\" .Ss Cleanup Routines
209.\" .Bl -tag -width indent
210.\" .El
211.Sh SEE ALSO
212.Xr libthr 3 ,
213.Xr pthread 3 ,
214.Xr pthread_affinity_np 3 ,
215.Xr pthread_attr_affinity_np 3 ,
216.Xr pthread_attr_get_np 3 ,
217.Xr pthread_attr_setcreatesuspend_np 3 ,
218.Xr pthread_getthreadid_np 3 ,
219.Xr pthread_join 3 ,
220.Xr pthread_main_np 3 ,
221.Xr pthread_multi_np 3 ,
222.Xr pthread_mutexattr_getkind_np 3 ,
223.Xr pthread_resume_all_np 3 ,
224.Xr pthread_resume_np 3 ,
225.Xr pthread_set_name_np 3 ,
226.Xr pthread_suspend_all_np 3 ,
227.Xr pthread_suspend_np 3 ,
228.Xr pthread_switch_add_np 3
229.Sh STANDARDS
230All of these functions are non-portable extensions to POSIX threads.
231