UNR(9) | Kernel Developer's Manual | UNR(9) |
new_unrhdr
,
clear_unrhdr
, delete_unrhdr
,
alloc_unr
,
alloc_unr_specific
, free_unr
— kernel unit number allocator
#include
<sys/systm.h>
struct unrhdr *
new_unrhdr
(int
low, int high,
struct mtx *mutex);
void
clear_unrhdr
(struct
unrhdr *uh);
void
delete_unrhdr
(struct
unrhdr *uh);
int
alloc_unr
(struct
unrhdr *uh);
int
alloc_unrl
(struct
unrhdr *uh);
int
alloc_unr_specific
(struct
unrhdr *uh, u_int
item);
void
free_unr
(struct
unrhdr *uh, u_int
item);
The kernel unit number allocator is a generic facility, which allows to allocate unit numbers within a specified range.
new_unrhdr
(low,
high, mutex)INT_MAX
can be used. If
mutex is not NULL
, it is
used for locking when allocating and freeing units. Otherwise, internal
mutex is used.clear_unrhdr
(uh)new_unrhdr
().delete_unrhdr
(uh)clear_unrhdr
().alloc_unr
(uh)-1
is returned.alloc_unrl
(uh)alloc_unr
() except that mutex is assumed
to be already locked and thus is not used.alloc_unr_specific
(uh,
item)-1
is returned.free_unr
(uh,
item)The above functions are implemented in sys/kern/subr_unit.c.
Kernel unit number allocator first appeared in FreeBSD 6.0.
Kernel unit number allocator was written by Poul-Henning Kamp. This manpage was written by Gleb Smirnoff.
October 4, 2017 | Debian |