Multi-processor fixed-size buffer heap using hardware queues.
============================================================================
Heap implementation that manages fixed size buffers that can be used in a multiprocessor system with shared memory.
The HeapQueueMgr manager provides functions to allocate and free storage from a heap of type HeapQueueMgr which inherits from IHeap. HeapQueueMgr manages a single fixed-size buffer, split into equally sized allocatable blocks.
The HeapQueueMgr manager is intended as a very fast memory manager which can only allocate blocks of a single size. It is ideal for managing a heap that is only used for allocating a single type of object, or for objects that have very similar sizes.
The HeapQueueMgr module uses a NameServer instance to store instance information when an instance is created. The name supplied must be unique for all HeapQueueMgr instances.
The HeapQueueMgr_create call initializes the shared memory as needed. Once an instance is created, a HeapQueueMgr_open can be performed. The open is used to gain access to the same HeapQueueMgr instance. Generally an instance is created on one processor and opened on the other processor(s).
The open returns a HeapQueueMgr instance handle like the create, however the open does not modify the shared memory.
The HeapBufQueueMgr header should be included in an application as follows:
#include <ti/ipc/HeapBufQueueMgr.h>
#include <ti/ipc/GateMP.h>
Go to the source code of this file.
Data Structures | |
struct | HeapQueueMgr_Params |
Structure defining parameters for the HeapQueueMgr module. More... | |
Defines | |
#define | HeapQueueMgr_S_BUSY 2 |
The resource is still in use. | |
#define | HeapQueueMgr_S_ALREADYSETUP 1 |
The module has been already setup. | |
#define | HeapQueueMgr_S_SUCCESS 0 |
Operation is successful. | |
#define | HeapQueueMgr_E_FAIL -1 |
Generic failure. | |
#define | HeapQueueMgr_E_INVALIDARG -2 |
Argument passed to function is invalid. | |
#define | HeapQueueMgr_E_MEMORY -3 |
Operation resulted in memory failure. | |
#define | HeapQueueMgr_E_ALREADYEXISTS -4 |
The specified entity already exists. | |
#define | HeapQueueMgr_E_NOTFOUND -5 |
Unable to find the specified entity. | |
#define | HeapQueueMgr_E_TIMEOUT -6 |
Operation timed out. | |
#define | HeapQueueMgr_E_INVALIDSTATE -7 |
Module is not initialized. | |
#define | HeapQueueMgr_E_OSFAILURE -8 |
A failure occurred in an OS-specific call. | |
#define | HeapQueueMgr_E_RESOURCE -9 |
Specified resource is not available. | |
#define | HeapQueueMgr_E_RESTART -10 |
Operation was interrupted. Please restart the operation. | |
Typedefs | |
typedef struct HeapQueueMgr_Object * | HeapQueueMgr_Handle |
HeapQueueMgr_Handle type. | |
typedef struct HeapQueueMgr_Params | HeapQueueMgr_Params |
Structure defining parameters for the HeapQueueMgr module. | |
Functions | |
Int | HeapQueueMgr_close (HeapQueueMgr_Handle *handlePtr) |
Close a HeapQueueMgr instance. | |
HeapQueueMgr_Handle | HeapQueueMgr_create (const HeapQueueMgr_Params *params) |
Create a HeapQueueMgr instance. | |
Int | HeapQueueMgr_delete (HeapQueueMgr_Handle *handlePtr) |
Delete a created HeapQueueMgr instance. | |
Int | HeapQueueMgr_open (String name, HeapQueueMgr_Handle *handlePtr) |
Open a created HeapQueueMgr instance. | |
Void | HeapQueueMgr_Params_init (HeapQueueMgr_Params *params) |
Initialize a HeapQueueMgr parameters struct. | |
Void * | HeapQueueMgr_alloc (HeapQueueMgr_Handle handle, SizeT size, SizeT align) |
Allocate a block of memory of specified size and alignment. | |
Void | HeapQueueMgr_free (HeapQueueMgr_Handle handle, Ptr block, SizeT size) |
Frees a block of memory. | |
Void | HeapQueueMgr_getStats (HeapQueueMgr_Handle handle, Ptr stats) |
Get memory statistics. |
#define HeapQueueMgr_S_BUSY 2 |
The resource is still in use.
#define HeapQueueMgr_S_ALREADYSETUP 1 |
The module has been already setup.
#define HeapQueueMgr_S_SUCCESS 0 |
Operation is successful.
#define HeapQueueMgr_E_FAIL -1 |
Generic failure.
#define HeapQueueMgr_E_INVALIDARG -2 |
Argument passed to function is invalid.
#define HeapQueueMgr_E_MEMORY -3 |
Operation resulted in memory failure.
#define HeapQueueMgr_E_ALREADYEXISTS -4 |
The specified entity already exists.
#define HeapQueueMgr_E_NOTFOUND -5 |
Unable to find the specified entity.
#define HeapQueueMgr_E_TIMEOUT -6 |
Operation timed out.
#define HeapQueueMgr_E_INVALIDSTATE -7 |
Module is not initialized.
#define HeapQueueMgr_E_OSFAILURE -8 |
A failure occurred in an OS-specific call.
#define HeapQueueMgr_E_RESOURCE -9 |
Specified resource is not available.
#define HeapQueueMgr_E_RESTART -10 |
Operation was interrupted. Please restart the operation.
typedef struct HeapQueueMgr_Object* HeapQueueMgr_Handle |
HeapQueueMgr_Handle type.
typedef struct HeapQueueMgr_Params HeapQueueMgr_Params |
Structure defining parameters for the HeapQueueMgr module.
Int HeapQueueMgr_close | ( | HeapQueueMgr_Handle * | handlePtr ) |
Close a HeapQueueMgr instance.
Closing an instance will free local memory consumed by the opened instance. All opened instances should be closed before the instance is deleted.
handlePtr | Pointer to handle returned from HeapQueueMgr_open |
HeapQueueMgr_Handle HeapQueueMgr_create | ( | const HeapQueueMgr_Params * | params ) |
Create a HeapQueueMgr instance.
params | HeapQueueMgr parameters |
Int HeapQueueMgr_delete | ( | HeapQueueMgr_Handle * | handlePtr ) |
Delete a created HeapQueueMgr instance.
handlePtr | Pointer to handle to delete. |
Int HeapQueueMgr_open | ( | String | name, |
HeapQueueMgr_Handle * | handlePtr | ||
) |
Open a created HeapQueueMgr instance.
Once an instance is created, an open can be performed. The open is used to gain access to the same HeapQueueMgr instance. Generally an instance is created on one processor and opened on the other processor.
The open returns a HeapQueueMgr instance handle like the create, however the open does not initialize the shared memory. The supplied name is used to identify the created instance.
Call HeapQueueMgr_close when the opened instance is not longer needed.
name | Name of created HeapQueueMgr instance |
handlePtr | Pointer to HeapQueueMgr handle to be opened |
Void HeapQueueMgr_Params_init | ( | HeapQueueMgr_Params * | params ) |
Initialize a HeapQueueMgr parameters struct.
[out] | params | Pointer to GateMP parameters |
Void* HeapQueueMgr_alloc | ( | HeapQueueMgr_Handle | handle, |
SizeT | size, | ||
SizeT | align | ||
) |
Allocate a block of memory of specified size and alignment.
The actual block returned may be larger than requested to satisfy alignment requirements.
HeapQueueMgr_alloc will lock the heap using the HeapQueueMgr gate while it traverses the list of free blocks to find a large enough block for the request.
Guidelines for using large heaps and multiple alloc() calls.
handle | Handle to previously created/opened instance. |
size | Size to be allocated (in MADUs) |
align | Alignment for allocation (power of 2) |
Void HeapQueueMgr_free | ( | HeapQueueMgr_Handle | handle, |
Ptr | block, | ||
SizeT | size | ||
) |
Frees a block of memory.
free() places the memory block specified by addr and size back into the free pool of the heap specified. The newly freed block is combined with any adjacent free blocks. The space is then available for further allocation by alloc().
HeapQueueMgr_free will lock the heap using the HeapQueueMgr gate if one is specified or the system GateMP if not.
handle | Handle to previously created/opened instance. |
block | Block of memory to be freed. |
size | Size to be freed (in MADUs) |
Void HeapQueueMgr_getStats | ( | HeapQueueMgr_Handle | handle, |
Ptr | stats | ||
) |
Get memory statistics.
[in] | handle | Handle to previously created/opened instance. |
[out] | stats | Memory statistics structure |