---
name: "dllockinit"
section: "3"
platform: "freebsd"
package: "base"
version: "16.0-CURRENT-20261027-61c70dc16a79"
release: "FreeBSD 16.0-CURRENT (2026-10-27)"
platforms: ["freebsd"]
url: "https://new.carta.tech/dllockinit"
---

# dllockinit(3)

register thread locking methods with the dynamic linker

## NAME

**dllockinit** – register thread locking methods with the dynamic linker

## LIBRARY

Standard C Library (libc, -lc)

## SYNOPSIS

**#include \<dlfcn.h\>**

*void*\

**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)*);

## DESCRIPTION

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.

Threads packages can call **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.

The *context* argument specifies an opaque context for creating locks. The dynamic linker will pass it to the *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 **dllockinit**() to register new locking functions) it will call *context\_destroy* to destroy the context.

The *lock\_create* argument specifies a function for creating a read/write lock. It must return a pointer to the new lock.

The *rlock\_acquire* and *wlock\_acquire* arguments specify functions which lock a lock for reading or writing, respectively. The *lock\_release* argument specifies a function which unlocks a lock. Each of these functions is passed a pointer to the lock.

The *lock\_destroy* argument specifies a function to destroy a lock. It may be NULL if locks do not need to be destroyed. The *context\_destroy* argument specifies a function to destroy the context. It may be NULL if the context does not need to be destroyed.

Until **dllockinit**() is called, the dynamic linker protects its critical sections using a default locking mechanism which works by blocking the SIGVTALRM, SIGPROF, and 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 **dllockinit**() can restore the default locking by calling **dllockinit**() with all arguments NULL.

## SEE ALSO

[rtld(1)](/rtld/1.md), [signal(3)](/signal/3.md)

## HISTORY

The **dllockinit**() function first appeared in FreeBSD 4.0.
