NAME | SYNOPSIS | FEATURES | DESCRIPTION | EXTENDED DESCRIPTION | Allowed Calling Contexts | ATTRIBUTES
#include <dki/dki.h>void * svMemAlloc(unsigned int size);
DKI
Provides general purpose memory allocation.
The microkernel provides general purpose memory management services for device drivers that need to allocate and free sized pieces of memory dynamically in a supervisor address space. As the initialization scheme is mainly dynamic, device drivers need to dynamically allocate/free small pieces of supervisor data. Typically, a device driver needs to dynamically allocate data associated with each instance to be registered in the Device Registry at initialization time.
Moreover, most of the DDI services called from base level by the driver clients leads to dynamic allocation/freeing of a number of linked list elements for internal management purposes. Note that the memory allocated using these services is anonymous; it is not associated with any actor context. For this reason, all the memory allocated must be explicitly freed by the drivers before they terminate, as the kernel cannot do it at actor deletion time.
svMemAlloc allocates memory of a given size which is accessible within the supervisor address space. The size argument specifies the required memory size. In case of success, svMemAlloc returns a pointer to the supervisor memory allocated, otherwise a NULL pointer is returned. The allocated memory returned by svMemAlloc is suitably aligned for any use.
The svMemFree routine frees memory previously allocated using svMemAlloc . The mem argument specifies the pointer to the memory previously returned by svMemAlloc . The size argument must be exactly the same as the size required when previously allocating the memory using svMemAlloc .
The following table specifies the contexts in which a caller is allowed to invoke each service.
Services | Base level | DKI thread | Interrupt | Blocking |
svMemAlloc | + | + | - | + |
svMemFree | + | + | - | + |
See attributes(5) for descriptions of the following attributes:
ATTRIBUTE TYPE | ATTRIBUTE VALUE |
---|---|
Interface Stability | Evolving |
NAME | SYNOPSIS | FEATURES | DESCRIPTION | EXTENDED DESCRIPTION | Allowed Calling Contexts | ATTRIBUTES