1d3980376SJohn Polstra.\" 24e1635feSJohn Polstra.\" Copyright (c) 1999, 2000 John D. Polstra 3d3980376SJohn Polstra.\" All rights reserved. 4d3980376SJohn Polstra.\" 5d3980376SJohn Polstra.\" Redistribution and use in source and binary forms, with or without 6d3980376SJohn Polstra.\" modification, are permitted provided that the following conditions 7d3980376SJohn Polstra.\" are met: 8d3980376SJohn Polstra.\" 1. Redistributions of source code must retain the above copyright 9d3980376SJohn Polstra.\" notice, this list of conditions and the following disclaimer. 10d3980376SJohn Polstra.\" 2. Redistributions in binary form must reproduce the above copyright 11d3980376SJohn Polstra.\" notice, this list of conditions and the following disclaimer in the 12d3980376SJohn Polstra.\" documentation and/or other materials provided with the distribution. 13d3980376SJohn Polstra.\" 14d3980376SJohn Polstra.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 15d3980376SJohn Polstra.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16d3980376SJohn Polstra.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17d3980376SJohn Polstra.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 18d3980376SJohn Polstra.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 19d3980376SJohn Polstra.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 20d3980376SJohn Polstra.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21d3980376SJohn Polstra.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22d3980376SJohn Polstra.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23d3980376SJohn Polstra.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24d3980376SJohn Polstra.\" SUCH DAMAGE. 25d3980376SJohn Polstra.\" 26d3980376SJohn Polstra.\" $FreeBSD$ 27d3980376SJohn Polstra.\" 28d3980376SJohn Polstra.Dd December 26, 1999 29d3980376SJohn Polstra.Os FreeBSD 30d3980376SJohn Polstra.Dt DLLOCKINIT 3 31d3980376SJohn Polstra.Sh NAME 32d3980376SJohn Polstra.Nm dllockinit 33d3980376SJohn Polstra.Nd register thread locking methods with the dynamic linker 34d3980376SJohn Polstra.Sh SYNOPSIS 35d3980376SJohn Polstra.Fd #include <dlfcn.h> 36d3980376SJohn Polstra.Ft void 37a37e09e4SBruce Evans.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)" 38d3980376SJohn Polstra.Sh DESCRIPTION 394e1635feSJohn Polstra.Bf Sy 404e1635feSJohn PolstraThis interface is experimental. It may be changed or eliminated in 414e1635feSJohn Polstrafuture releases. 424e1635feSJohn Polstra.Ef 434e1635feSJohn Polstra.Pp 44d3980376SJohn PolstraThreads packages can call 45d3980376SJohn Polstra.Nm 46d3980376SJohn Polstraat initialization time to register locking functions for the dynamic 47d3980376SJohn Polstralinker to use. This enables the dynamic linker to prevent multiple 48d3980376SJohn Polstrathreads from entering its critical sections simultaneously. 49d3980376SJohn Polstra.Pp 50d3980376SJohn PolstraThe 51d3980376SJohn Polstra.Fa context 52d3980376SJohn Polstraparameter specifies an opaque context for creating locks. The 53d3980376SJohn Polstradynamic linker will pass it to the 54d3980376SJohn Polstra.Fa lock_create 55d3980376SJohn Polstrafunction when creating the locks it needs. When the dynamic linker 56d3980376SJohn Polstrais permanently finished using the locking functions (e.g., if the 57d3980376SJohn Polstraprogram makes a subsequent call to 58d3980376SJohn Polstra.Nm 59d3980376SJohn Polstrato register new locking functions) it will call 60d3980376SJohn Polstra.Fa context_destroy 61d3980376SJohn Polstrato destroy the context. 62d3980376SJohn Polstra.Pp 63d3980376SJohn PolstraThe 64d3980376SJohn Polstra.Fa lock_create 65d3980376SJohn Polstraparameter specifies a function for creating a read/write lock. It 66d3980376SJohn Polstramust return a pointer to the new lock. 67d3980376SJohn Polstra.Pp 68d3980376SJohn PolstraThe 69d3980376SJohn Polstra.Fa rlock_acquire 70d3980376SJohn Polstraand 71d3980376SJohn Polstra.Fa wlock_acquire 72d3980376SJohn Polstraparameters specify functions which lock a lock for reading or 73d3980376SJohn Polstrawriting, respectively. The 74d3980376SJohn Polstra.Fa lock_release 75d3980376SJohn Polstraparameter specifies a function which unlocks a lock. Each of these 76d3980376SJohn Polstrafunctions is passed a pointer to the lock. 77d3980376SJohn Polstra.Pp 78d3980376SJohn PolstraThe 79d3980376SJohn Polstra.Fa lock_destroy 80d3980376SJohn Polstraparameter specifies a function to destroy a lock. It may be 81d3980376SJohn Polstra.Dv NULL 82d3980376SJohn Polstraif locks do not need to be destroyed. The 83d3980376SJohn Polstra.Fa context_destroy 847f205788SJohn Polstraparameter specifies a function to destroy the context. It may be 85d3980376SJohn Polstra.Dv NULL 86d3980376SJohn Polstraif the context does not need to be destroyed. 87d3980376SJohn Polstra.Pp 887f205788SJohn PolstraUntil 89d3980376SJohn Polstra.Nm 907f205788SJohn Polstrais called, the dynamic linker protects its critical sections using 917f205788SJohn Polstraa default locking mechanism which works by blocking the 92d3980376SJohn Polstra.Dv SIGVTALRM , 93d3980376SJohn Polstra.Dv SIGPROF , 94d3980376SJohn Polstraand 95d3980376SJohn Polstra.Dv SIGALRM 96d3980376SJohn Polstrasignals. This is sufficient for many application level threads 97d3980376SJohn Polstrapackages, which typically use one of these signals to implement 98d3980376SJohn Polstrapreemption. An application which has registered its own locking 99d3980376SJohn Polstramethods with 100d3980376SJohn Polstra.Nm 101d3980376SJohn Polstracan restore the default locking by calling 102d3980376SJohn Polstra.Nm 103d3980376SJohn Polstrawith all arguments 104d3980376SJohn Polstra.Dv NULL . 105d3980376SJohn Polstra.Sh SEE ALSO 106d3980376SJohn Polstra.Xr rtld 1 , 107d3980376SJohn Polstra.Xr signal 3 108d3980376SJohn Polstra.Sh HISTORY 109d3980376SJohn PolstraThe 110d3980376SJohn Polstra.Nm 111d3980376SJohn Polstrafunction first appeared in FreeBSD 4.0. 112