FreeBSD ZFS
The Zettabyte File System
|
Zero Reference Locks. More...
#include <sys/zrlock.h>
Go to the source code of this file.
Defines | |
#define | ZRL_LOCKED ((uint32_t)-1) |
#define | ZRL_DESTROYED -2 |
Functions | |
void | zrl_init (zrlock_t *zrl) |
void | zrl_destroy (zrlock_t *zrl) |
void | zrl_add (zrlock_t *zrl) |
void | zrl_remove (zrlock_t *zrl) |
int | zrl_tryenter (zrlock_t *zrl) |
void | zrl_exit (zrlock_t *zrl) |
int | zrl_refcount (zrlock_t *zrl) |
int | zrl_is_zero (zrlock_t *zrl) |
int | zrl_is_locked (zrlock_t *zrl) |
Zero Reference Locks.
A Zero Reference Lock (ZRL) is a reference count that can lock out new references only when the count is zero and only without waiting if the count is not already zero. It is similar to a read-write lock in that it allows multiple readers and only a single writer, but it does not allow a writer to block while waiting for readers to exit, and therefore the question of reader/writer priority is moot (no WRWANT bit). Since the equivalent of rw_enter(&lock, RW_WRITER) is disallowed and only tryenter() is allowed, it is perfectly safe for the same reader to acquire the same lock multiple times. The fact that a ZRL is reentrant for readers (through multiple calls to zrl_add()) makes it convenient for determining whether something is actively referenced without the fuss of flagging lock ownership across function calls.
Definition in file zrlock.c.