The kernel unit number allocator is a generic facility, which allows to allocate
unit numbers within a specified range.
|new_unrhdr(low, high, mutex)
Initialize a new unit number allocator entity.
specify minimum and maximum number of unit numbers.
There is no cost associated with the range of unit numbers, so unless the resource
really is finite,
can be used.
it is used for locking when allocating and freeing units.
Otherwise, internal mutex is used.
Destroy specified unit number allocator entity.
Return a new unit number.
The lowest free number is always allocated.
This function does not allocate memory and never sleeps, however it may
block on a mutex.
If no free unit numbers are left,
except that mutex is assumed to be already locked and thus is not used.
Allocate a specific unit number.
This function allocates memory and thus may sleep.
The allocated unit number is returned on success.
If the specified number is already allocated or out of the range,
Free a previously allocated unit number.
This function may require allocating memory, and thus it can sleep.
There is no pre-locked variant.