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