Museum

Home

Lab Overview

Retrotechnology Articles

Online Manuals

⇒ kmem_zalloc(D3DK) — Motorola System V 88k Release 4 Version 4.3

Media Vault

Software Library

Restoration Projects

Artifacts Sought

kmem_zalloc(D3DK)  —  

NAME

kmem_zalloc − allocate and clear space from kernel free memory .IX \f4kmem_zalloc\fP(D3DK)

SYNOPSIS

#include <sys/types.h>
#include <sys/kmem.h>
void ∗kmem_zalloc(size_t size, int flag);

ARGUMENTS

sizeNumber of bytes to allocate. 

flagSpecifies 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. 

DESCRIPTION

kmem_zalloc allocates size bytes of kernel memory, clears the memory by filling it with zeros, and returns a pointer to the allocated memory. 

RETURN VALUE

Upon successful completion, kmem_zalloc returns a pointer to the allocated memory.  If KM_NOSLEEP is specified and sufficient memory is not immediately available, kmem_zalloc returns a NULL pointer.  If size is set to 0, kmem_zalloc returns NULL regardless of the value of flag. 

LEVEL

Base only if flag is set to KM_SLEEP.  Base or interrupt if flag is set to KM_NOSLEEP. 

NOTES

May sleep if flag is set to KM_SLEEP. 

Driver-defined basic locks and read/write locks may be held across calls to this function if flag is KM_NOSLEEP but may not be held if flag is KM_SLEEP. 

Driver-defined sleep locks may be held across calls to this function regardless of the value of flag. 

Kernel memory is a limited resource and should be used judiciously.  Memory allocated using kmem_zalloc should be freed as soon as possible.  Drivers should not use local freelists for memory or similar schemes that cause the memory to be held for longer than necessary. 

Since holding memory allocated using kmem_zalloc for extended periods of time (e.g allocating memory at system startup and never freeing it) can have an adverse effect on overall memory usage and system performance, memory needed for such extended periods should be statically allocated whenever possible. 

The address returned by a successful call to kmem_zalloc is word-aligned. 

SEE ALSO

kmem_alloc(D3DK), kmem_free(D3DK)

DDI/DKI

Typewritten Software • bear@typewritten.org • Edmonds, WA 98026