kmem_alloc(9F)
NAME
kmem_alloc − allocate space from kernel free memory
SYNOPSIS
#include <sys/types.h>
#include <sys/kmem.h>
void ∗kmem_alloc(size_t size, int flag);
ARGUMENTS
size Number of bytes to allocate.
flag Determines if caller will sleep to wait for free space. Possible flags are KM_SLEEP to sleep while waiting for free space, and KM_NOSLEEP to return NULL if space is not available.
INTERFACE LEVEL
Architecture independent level 1 (DDI/DKI).
DESCRIPTION
kmem_alloc() allocates a specified amount of kernel memory in bytes and returns a pointer to the allocated memory. The flag argument determines whether the function will sleep while waiting for free space to be released. If flag has KM_SLEEP set, the caller may sleep until free space is available. If flag has KM_NOSLEEP set and space is not available, NULL will be returned.
RETURN VALUES
If successful, kmem_alloc() returns a pointer to the allocated space. NULL is returned if KM_NOSLEEP is set and memory cannot be allocated.
CONTEXT
kmem_alloc() can be called from interrupt context only if the KM_NOSLEEP flag is set. It can be called from user context with any valid flag.
SEE ALSO
freerbuf(9F), getrbuf(9F), kmem_free(9F), kmem_zalloc(9F)
WARNINGS
Memory allocated by kmem_alloc() is not paged. Available memory is therefore limited. Excessive use of this memory is likely to affect overall system performance.
SunOS 5.2 — Last change: 11 Apr 1991