allocate and clear space from kernel free memory
void *kmem_zalloc(size_t size, int flag);
kmem_zalloc allocates size bytes of kernel
memory, clears the memory by filling it with zeros,
and returns a pointer to the allocated memory.
Number of bytes to allocate.
Specifies whether the caller is willing to sleep waiting for memory.
If flag is set to KM_SLEEP, the caller will sleep
if necessary until the specified amount of memory is available.
If flag is set to KM_NOSLEEP, the caller will not sleep,
but kmem_zalloc will return NULL if the specified amount
of memory is not immediately available.
Upon successful completion,
returns a pointer to the allocated memory.
If KM_NOSLEEP is specified
and sufficient memory is not immediately available,
returns a NULL pointer.
If size is set to 0,
regardless of the value of flag.
The address returned by a successful call to kmem_zalloc is
Drivers should not assume that memory allocated by
is usable for DMA operations,
nor should drivers assume that the
memory has any specific physical properties
such as starting address alignment,
physical address range,
or physical contiguity.
Context and synchronization
If flag is set to KM_NOSLEEP,
non-blockable, initialization, or interrupt
If flag is set to KM_SLEEP,
1, 2, 3, 4, 5, 5mp, 6, 6mp, 7, 7mp, 7.1, 7.1mp, 8, 8mp
Differences between versions
In versions 1, 2, 3, 4, 5, and 5mp,
the memory returned by kmem_zalloc
is DMA-able; that is,
it will satisfy worst-case DMA-ability requirements
on systems with restricted DMA; see phys_dmasize of
In versions 1, 2, 3, and 4, the memory returned will also be physically
contiguous, if possible (guaranteed if size is less than or equal to
For other versions, there are no guarantees on the memory properties.
is also supported on SCO OpenServer, but memory allocated
is DMA-able (contiguous)
unless the KM_NO_DMA flag is specified
Beginning with DDI version 8,
memory with specific physical properties
can be allocated with the
Beginning with DDI version 6,
memory with specific physical properties can
be obtained through
In DDI version 5,
contiguous memory with specific physical properties
can be obtained through
``Memory allocation'' in HDK Technical Reference
19 June 2005
© 2005 The SCO Group, Inc. All rights reserved.
OpenServer 6 and UnixWare (SVR5) HDK - June 2005