xref: /netbsd-src/lib/libpthread/threads.3 (revision 1dcc5901106d4eab58b070fee25ec903eaf8ac04)
1*1dcc5901Swiz.\"	$NetBSD: threads.3,v 1.2 2019/04/27 10:57:11 wiz Exp $
2a9ca1710Skamil.\"
3a9ca1710Skamil.\" Copyright (c) 2016 The NetBSD Foundation, Inc.
4a9ca1710Skamil.\" All rights reserved.
5a9ca1710Skamil.\"
6a9ca1710Skamil.\" This code is derived from software contributed to The NetBSD Foundation
7a9ca1710Skamil.\" by Kamil Rytarowski.
8a9ca1710Skamil.\"
9a9ca1710Skamil.\" Redistribution and use in source and binary forms, with or without
10a9ca1710Skamil.\" modification, are permitted provided that the following conditions
11a9ca1710Skamil.\" are met:
12a9ca1710Skamil.\" 1. Redistributions of source code must retain the above copyright
13a9ca1710Skamil.\"    notice, this list of conditions and the following disclaimer.
14a9ca1710Skamil.\" 2. Redistributions in binary form must reproduce the above copyright
15a9ca1710Skamil.\"    notice, this list of conditions and the following disclaimer in the
16a9ca1710Skamil.\"    documentation and/or other materials provided with the distribution.
17a9ca1710Skamil.\"
18a9ca1710Skamil.\" THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
19a9ca1710Skamil.\" ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
20a9ca1710Skamil.\" TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
21a9ca1710Skamil.\" PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
22a9ca1710Skamil.\" BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
23a9ca1710Skamil.\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
24a9ca1710Skamil.\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
25a9ca1710Skamil.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
26a9ca1710Skamil.\" CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
27a9ca1710Skamil.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
28a9ca1710Skamil.\" POSSIBILITY OF SUCH DAMAGE.
29a9ca1710Skamil.\"
30a9ca1710Skamil.Dd October 16, 2016
31*1dcc5901Swiz.Dt THREADS 3
32a9ca1710Skamil.Os
33a9ca1710Skamil.Sh NAME
34a9ca1710Skamil.Nm threads
35a9ca1710Skamil.Nd C11 thread support library
36a9ca1710Skamil.Sh LIBRARY
37a9ca1710Skamil.Lb libpthread
38a9ca1710Skamil.Sh SYNOPSIS
39a9ca1710Skamil.In threads.h
40a9ca1710Skamil.Sh DESCRIPTION
41*1dcc5901SwizThe C11 thread support library provides an implementation of a portable threading
42a9ca1710Skamilinterface, built on top of the
43a9ca1710Skamil.Xr pthread 3
44a9ca1710Skamilnative interfaces.
45a9ca1710SkamilThis library is composed of:
46a9ca1710Skamil.Bl -dash
47a9ca1710Skamil.It
48a9ca1710SkamilInitialization functions.
49a9ca1710Skamil.It
50a9ca1710SkamilCondition variable functions.
51a9ca1710Skamil.It
52a9ca1710SkamilMutex functions.
53a9ca1710Skamil.It
54a9ca1710SkamilThread functions.
55a9ca1710Skamil.It
56a9ca1710SkamilThread-specifig storage functions.
57a9ca1710Skamil.El
58a9ca1710Skamil.Bl -column "mtx_timedwait"
59a9ca1710Skamil.It Sy "Function"      Ta Sy "Summary"
60a9ca1710Skamil.It Xr call_once 3     Ta calls function exactly once
61a9ca1710Skamil.It Xr cnd_broadcast 3 Ta unblocks all threads blocked on a condition
62a9ca1710Skamil.It Xr cnd_destroy 3   Ta releases all resources used by a condition
63a9ca1710Skamil.It Xr cnd_init 3      Ta creates a condition variable
64a9ca1710Skamil.It Xr cnd_signal 3    Ta unblocks one of threads blocked on a condition
65a9ca1710Skamil.It Xr cnd_timedwait 3 Ta unlocks a mutex and blocks until a signal or timeout
66a9ca1710Skamil.It Xr cnd_wait 3      Ta unlocks a mutex and blocks until a signal
67a9ca1710Skamil.It Xr mtx_destroy 3   Ta releases resources used by a mutex
68a9ca1710Skamil.It Xr mtx_init 3      Ta creates a mutex object with requested properties
69a9ca1710Skamil.It Xr mtx_lock 3      Ta blocks on a mutex optionally with a recursive type
70a9ca1710Skamil.It Xr mtx_timedwait 3 Ta tries to block until it locks a mutex or timeout
71a9ca1710Skamil.It Xr mtx_trylock 3   Ta tries to lock a mutex
72a9ca1710Skamil.It Xr mtx_unlock 3    Ta unlocks a mutex
73a9ca1710Skamil.It Xr thrd_create 3   Ta creates a thread executing a function with a parameter
74a9ca1710Skamil.It Xr thrd_current 3  Ta identifies the thread that called this function
75*1dcc5901Swiz.It Xr thrd_detach 3   Ta dispose of resources allocated to a thread on exit
76*1dcc5901Swiz.It Xr thrd_equal 3    Ta determines whether two threads refer the same thread
77a9ca1710Skamil.It Xr thrd_exit 3     Ta terminates a calling thread and sets its result code
78a9ca1710Skamil.It Xr thrd_join 3     Ta joins a thread with the current one and blocks
79a9ca1710Skamil.It Xr thrd_sleep 3    Ta suspends a calling thread until a signal or timeout
80*1dcc5901Swiz.It Xr tss_create 3    Ta creates a thread-specific storage pointer with a destructor
81a9ca1710Skamil.It Xr tss_delete 3    Ta releases resources used by a thread-specific storage
82a9ca1710Skamil.It Xr tss_get 3       Ta gets a value of thread-specific storage from a key
83a9ca1710Skamil.It Xr tss_set 3       Ta sets a value of thread-specific storage to a key
84a9ca1710Skamil.El
85a9ca1710Skamil.Sh SEE ALSO
86a9ca1710Skamil.Xr c11 1 ,
87a9ca1710Skamil.Xr pthread 3 ,
88a9ca1710Skamil.Xr c 7
89a9ca1710Skamil.Sh STANDARDS
90a9ca1710SkamilThe
91a9ca1710Skamil.Nm
92a9ca1710Skamillibrary interfaces conform to
93a9ca1710Skamil.St -isoC-2011 .
94a9ca1710Skamil.Sh HISTORY
95a9ca1710SkamilThis interface first appeared in
96a9ca1710Skamil.Nx 9 .
97a9ca1710Skamil.Sh AUTHORS
98a9ca1710Skamil.An Kamil Rytarowski Aq Mt kamil@NetBSD.org
99