1999-12-27 04:44:04 +00:00
|
|
|
.\"
|
2000-01-29 01:33:21 +00:00
|
|
|
.\" Copyright (c) 1999, 2000 John D. Polstra
|
1999-12-27 04:44:04 +00:00
|
|
|
.\" 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$
|
|
|
|
.\"
|
2000-07-08 04:17:28 +00:00
|
|
|
.Dd July 5, 2000
|
1999-12-27 04:44:04 +00:00
|
|
|
.Dt DLLOCKINIT 3
|
2010-04-14 19:08:06 +00:00
|
|
|
.Os
|
1999-12-27 04:44:04 +00:00
|
|
|
.Sh NAME
|
|
|
|
.Nm dllockinit
|
|
|
|
.Nd register thread locking methods with the dynamic linker
|
2000-04-21 09:42:15 +00:00
|
|
|
.Sh LIBRARY
|
|
|
|
.Lb libc
|
1999-12-27 04:44:04 +00:00
|
|
|
.Sh SYNOPSIS
|
2001-10-01 16:09:29 +00:00
|
|
|
.In dlfcn.h
|
1999-12-27 04:44:04 +00:00
|
|
|
.Ft void
|
2000-01-05 19:04:55 +00:00
|
|
|
.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)"
|
1999-12-27 04:44:04 +00:00
|
|
|
.Sh DESCRIPTION
|
2000-01-29 01:33:21 +00:00
|
|
|
.Bf Sy
|
2000-07-08 04:17:28 +00:00
|
|
|
Due to enhancements in the dynamic linker, this interface is no longer
|
2004-07-02 23:52:20 +00:00
|
|
|
needed.
|
|
|
|
It is deprecated and will be removed from future releases.
|
2000-07-08 04:17:28 +00:00
|
|
|
In current releases it still exists, but only as a stub which does nothing.
|
2000-01-29 01:33:21 +00:00
|
|
|
.Ef
|
|
|
|
.Pp
|
1999-12-27 04:44:04 +00:00
|
|
|
Threads packages can call
|
2002-12-18 10:13:54 +00:00
|
|
|
.Fn dllockinit
|
1999-12-27 04:44:04 +00:00
|
|
|
at initialization time to register locking functions for the dynamic
|
2004-07-02 23:52:20 +00:00
|
|
|
linker to use.
|
|
|
|
This enables the dynamic linker to prevent multiple
|
1999-12-27 04:44:04 +00:00
|
|
|
threads from entering its critical sections simultaneously.
|
|
|
|
.Pp
|
|
|
|
The
|
|
|
|
.Fa context
|
2004-07-02 23:52:20 +00:00
|
|
|
argument specifies an opaque context for creating locks.
|
|
|
|
The
|
1999-12-27 04:44:04 +00:00
|
|
|
dynamic linker will pass it to the
|
|
|
|
.Fa lock_create
|
2004-07-02 23:52:20 +00:00
|
|
|
function when creating the locks it needs.
|
|
|
|
When the dynamic linker
|
1999-12-27 04:44:04 +00:00
|
|
|
is permanently finished using the locking functions (e.g., if the
|
|
|
|
program makes a subsequent call to
|
2002-12-18 10:13:54 +00:00
|
|
|
.Fn dllockinit
|
1999-12-27 04:44:04 +00:00
|
|
|
to register new locking functions) it will call
|
|
|
|
.Fa context_destroy
|
|
|
|
to destroy the context.
|
|
|
|
.Pp
|
|
|
|
The
|
|
|
|
.Fa lock_create
|
2004-07-02 23:52:20 +00:00
|
|
|
argument specifies a function for creating a read/write lock.
|
|
|
|
It
|
1999-12-27 04:44:04 +00:00
|
|
|
must return a pointer to the new lock.
|
|
|
|
.Pp
|
|
|
|
The
|
|
|
|
.Fa rlock_acquire
|
|
|
|
and
|
|
|
|
.Fa wlock_acquire
|
2002-12-19 09:40:28 +00:00
|
|
|
arguments specify functions which lock a lock for reading or
|
2004-07-02 23:52:20 +00:00
|
|
|
writing, respectively.
|
|
|
|
The
|
1999-12-27 04:44:04 +00:00
|
|
|
.Fa lock_release
|
2004-07-02 23:52:20 +00:00
|
|
|
argument specifies a function which unlocks a lock.
|
|
|
|
Each of these
|
1999-12-27 04:44:04 +00:00
|
|
|
functions is passed a pointer to the lock.
|
|
|
|
.Pp
|
|
|
|
The
|
|
|
|
.Fa lock_destroy
|
2004-07-02 23:52:20 +00:00
|
|
|
argument specifies a function to destroy a lock.
|
|
|
|
It may be
|
1999-12-27 04:44:04 +00:00
|
|
|
.Dv NULL
|
2004-07-02 23:52:20 +00:00
|
|
|
if locks do not need to be destroyed.
|
|
|
|
The
|
1999-12-27 04:44:04 +00:00
|
|
|
.Fa context_destroy
|
2004-07-02 23:52:20 +00:00
|
|
|
argument specifies a function to destroy the context.
|
|
|
|
It may be
|
1999-12-27 04:44:04 +00:00
|
|
|
.Dv NULL
|
|
|
|
if the context does not need to be destroyed.
|
|
|
|
.Pp
|
2000-01-09 21:01:39 +00:00
|
|
|
Until
|
2002-12-18 10:13:54 +00:00
|
|
|
.Fn dllockinit
|
2000-01-09 21:01:39 +00:00
|
|
|
is called, the dynamic linker protects its critical sections using
|
|
|
|
a default locking mechanism which works by blocking the
|
1999-12-27 04:44:04 +00:00
|
|
|
.Dv SIGVTALRM ,
|
|
|
|
.Dv SIGPROF ,
|
|
|
|
and
|
|
|
|
.Dv SIGALRM
|
2004-07-02 23:52:20 +00:00
|
|
|
signals.
|
|
|
|
This is sufficient for many application level threads
|
1999-12-27 04:44:04 +00:00
|
|
|
packages, which typically use one of these signals to implement
|
2004-07-02 23:52:20 +00:00
|
|
|
preemption.
|
|
|
|
An application which has registered its own locking
|
2000-10-30 13:23:19 +00:00
|
|
|
methods with
|
2002-12-18 10:13:54 +00:00
|
|
|
.Fn dllockinit
|
1999-12-27 04:44:04 +00:00
|
|
|
can restore the default locking by calling
|
2002-12-18 10:13:54 +00:00
|
|
|
.Fn dllockinit
|
1999-12-27 04:44:04 +00:00
|
|
|
with all arguments
|
|
|
|
.Dv NULL .
|
|
|
|
.Sh SEE ALSO
|
|
|
|
.Xr rtld 1 ,
|
|
|
|
.Xr signal 3
|
|
|
|
.Sh HISTORY
|
|
|
|
The
|
2002-12-18 10:13:54 +00:00
|
|
|
.Fn dllockinit
|
2000-11-14 11:20:58 +00:00
|
|
|
function first appeared in
|
|
|
|
.Fx 4.0 .
|