1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
|
.\"
.\" Copyright (c) 1999, 2000 John D. Polstra
.\" All rights reserved.
.\"
.\" Redistribution and use in source and binary forms, with or without
.\" modification, are permitted provided that the following conditions
.\" are met:
.\" 1. Redistributions of source code must retain the above copyright
.\" notice, this list of conditions and the following disclaimer.
.\" 2. Redistributions in binary form must reproduce the above copyright
.\" notice, this list of conditions and the following disclaimer in the
.\" documentation and/or other materials provided with the distribution.
.\"
.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
.\" $FreeBSD$
.\"
.Dd July 5, 2000
.Os
.Dt DLLOCKINIT 3
.Sh NAME
.Nm dllockinit
.Nd register thread locking methods with the dynamic linker
.Sh LIBRARY
.Lb libc
.Sh SYNOPSIS
.In dlfcn.h
.Ft void
.Fn dllockinit "void *context" "void *(*lock_create)(void *context)" "void (*rlock_acquire)(void *lock)" "void (*wlock_acquire)(void *lock)" "void (*lock_release)(void *lock)" "void (*lock_destroy)(void *lock)" "void (*context_destroy)(void *context)"
.Sh DESCRIPTION
.Bf Sy
Due to enhancements in the dynamic linker, this interface is no longer
needed. It is deprecated and will be removed from future releases.
In current releases it still exists, but only as a stub which does nothing.
.Ef
.Pp
Threads packages can call
.Fn dllockinit
at initialization time to register locking functions for the dynamic
linker to use. This enables the dynamic linker to prevent multiple
threads from entering its critical sections simultaneously.
.Pp
The
.Fa context
parameter specifies an opaque context for creating locks. The
dynamic linker will pass it to the
.Fa lock_create
function when creating the locks it needs. When the dynamic linker
is permanently finished using the locking functions (e.g., if the
program makes a subsequent call to
.Fn dllockinit
to register new locking functions) it will call
.Fa context_destroy
to destroy the context.
.Pp
The
.Fa lock_create
parameter specifies a function for creating a read/write lock. It
must return a pointer to the new lock.
.Pp
The
.Fa rlock_acquire
and
.Fa wlock_acquire
parameters specify functions which lock a lock for reading or
writing, respectively. The
.Fa lock_release
parameter specifies a function which unlocks a lock. Each of these
functions is passed a pointer to the lock.
.Pp
The
.Fa lock_destroy
parameter specifies a function to destroy a lock. It may be
.Dv NULL
if locks do not need to be destroyed. The
.Fa context_destroy
parameter specifies a function to destroy the context. It may be
.Dv NULL
if the context does not need to be destroyed.
.Pp
Until
.Fn dllockinit
is called, the dynamic linker protects its critical sections using
a default locking mechanism which works by blocking the
.Dv SIGVTALRM ,
.Dv SIGPROF ,
and
.Dv SIGALRM
signals. This is sufficient for many application level threads
packages, which typically use one of these signals to implement
preemption. An application which has registered its own locking
methods with
.Fn dllockinit
can restore the default locking by calling
.Fn dllockinit
with all arguments
.Dv NULL .
.Sh SEE ALSO
.Xr rtld 1 ,
.Xr signal 3
.Sh HISTORY
The
.Fn dllockinit
function first appeared in
.Fx 4.0 .
|