NAME | SYNOPSIS | API RESTRICTIONS | FEATURES | DESCRIPTION | EXTENDED DESCRIPTION | Allowed Calling Contexts | ATTRIBUTES
#include <dki/dki.h>void * svMemAlloc(unsigned int size);
The function or functions documented here may not be used safely in all application contexts with all APIs provided in the ChorusOS 5.0 product.
See API(5FEA) for details.
DKI
Provides general purpose memory allocation.
The microkernel provides general purpose memory management services for device drivers that need to allocate and free 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 lead to dynamic allocation/freeing of a number of linked list elements for internal management purposes.
The memory allocated using these services is anonymous and 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 microkernel cannot do it when deleting the actor.
svMemAlloc() allocates memory of a given size that 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 | API RESTRICTIONS | FEATURES | DESCRIPTION | EXTENDED DESCRIPTION | Allowed Calling Contexts | ATTRIBUTES