unr.9 (145333) | unr.9 (147432) |
---|---|
1.\" Copyright (c) 2005 Gleb Smirnoff <glebius@FreeBSD.org> 2.\" All rights reserved. 3.\" 4.\" Redistribution and use in source and binary forms, with or without 5.\" modification, are permitted provided that the following conditions 6.\" are met: 7.\" 1. Redistributions of source code must retain the above copyright 8.\" notice, this list of conditions and the following disclaimer. --- 8 unchanged lines hidden (view full) --- 17.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 18.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 19.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 20.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 21.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 22.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 23.\" SUCH DAMAGE. 24.\" | 1.\" Copyright (c) 2005 Gleb Smirnoff <glebius@FreeBSD.org> 2.\" All rights reserved. 3.\" 4.\" Redistribution and use in source and binary forms, with or without 5.\" modification, are permitted provided that the following conditions 6.\" are met: 7.\" 1. Redistributions of source code must retain the above copyright 8.\" notice, this list of conditions and the following disclaimer. --- 8 unchanged lines hidden (view full) --- 17.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 18.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 19.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 20.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 21.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 22.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 23.\" SUCH DAMAGE. 24.\" |
25.\" $FreeBSD: head/share/man/man9/alloc_unr.9 145333 2005-04-20 19:11:05Z glebius $ | 25.\" $FreeBSD: head/share/man/man9/alloc_unr.9 147432 2005-06-16 18:46:17Z ru $ |
26.\" 27.Dd March 23, 2005 28.Dt ALLOC_UNR 9 29.Os 30.Sh NAME 31.Nm new_unrhdr , 32.Nm delete_unrhdr , 33.Nm alloc_unr , --- 9 unchanged lines hidden (view full) --- 43.Fn alloc_unr "struct unrhdr *uh" 44.Ft int 45.Fn alloc_unrl "struct unrhdr *uh" 46.Ft void 47.Fn free_unr "struct unrhdr *uh" "u_int item" 48.Sh DESCRIPTION 49The kernel unit number allocator is a generic facility, which allows to allocate 50unit numbers within a specified range. | 26.\" 27.Dd March 23, 2005 28.Dt ALLOC_UNR 9 29.Os 30.Sh NAME 31.Nm new_unrhdr , 32.Nm delete_unrhdr , 33.Nm alloc_unr , --- 9 unchanged lines hidden (view full) --- 43.Fn alloc_unr "struct unrhdr *uh" 44.Ft int 45.Fn alloc_unrl "struct unrhdr *uh" 46.Ft void 47.Fn free_unr "struct unrhdr *uh" "u_int item" 48.Sh DESCRIPTION 49The kernel unit number allocator is a generic facility, which allows to allocate 50unit numbers within a specified range. |
51.Bl -ohang | 51.Bl -tag -width indent |
52.It Fn new_unrhdr low high mutex 53Initialize a new unit number allocator entity. | 52.It Fn new_unrhdr low high mutex 53Initialize a new unit number allocator entity. |
54The |
|
54.Fa low 55and 56.Fa high | 55.Fa low 56and 57.Fa high |
58arguments |
|
57specify minimum and maximum number of unit numbers. 58There is no cost associated with the range of unit numbers, so unless the resource 59really is finite, | 59specify minimum and maximum number of unit numbers. 60There is no cost associated with the range of unit numbers, so unless the resource 61really is finite, |
60.Va INT_MAX | 62.Dv INT_MAX |
61can be used. 62If 63.Fa mutex 64is not | 63can be used. 64If 65.Fa mutex 66is not |
65.Va NULL , | 67.Dv NULL , |
66it is used for locking when allocating and freeing units. | 68it is used for locking when allocating and freeing units. |
67Otherwise internal mutex is used. | 69Otherwise, internal mutex is used. |
68.It Fn delete_unrhdr uh 69Destroy specified unit number allocator entity. 70.It Fn alloc_unr uh 71Return a new unit number. 72The lowest free number is always allocated. 73This function does not allocate memory and never sleeps, however it may | 70.It Fn delete_unrhdr uh 71Destroy specified unit number allocator entity. 72.It Fn alloc_unr uh 73Return a new unit number. 74The lowest free number is always allocated. 75This function does not allocate memory and never sleeps, however it may |
74block on mutex. 75If no free unit numbers are left 76.Va -1 | 76block on a mutex. 77If no free unit numbers are left, 78.Li \-1 |
77is returned. 78.It Fn alloc_unrl uh 79Same as 80.Fn alloc_unr | 79is returned. 80.It Fn alloc_unrl uh 81Same as 82.Fn alloc_unr |
81except that mutex is assumed to be locked already and thus is not used. | 83except that mutex is assumed to be already locked and thus is not used. |
82.It Fn free_unr uh 83Free a previously allocated unit number. 84This function may require allocating memory, and thus it can sleep. 85There is no pre-locked variant. 86.El 87.Sh CODE REFERENCES 88The above functions are implemented in 89.Pa sys/kern/subr_unit.c . 90.Sh HISTORY 91Kernel unit number allocator first appeared in 92.Fx 5.5 . 93.Sh AUTHORS 94.An -nosplit 95Kernel unit number allocator was written by 96.An Poul-Henning Kamp . 97This manpage was written by 98.An Gleb Smirnoff . | 84.It Fn free_unr uh 85Free a previously allocated unit number. 86This function may require allocating memory, and thus it can sleep. 87There is no pre-locked variant. 88.El 89.Sh CODE REFERENCES 90The above functions are implemented in 91.Pa sys/kern/subr_unit.c . 92.Sh HISTORY 93Kernel unit number allocator first appeared in 94.Fx 5.5 . 95.Sh AUTHORS 96.An -nosplit 97Kernel unit number allocator was written by 98.An Poul-Henning Kamp . 99This manpage was written by 100.An Gleb Smirnoff . |