Data Structures | Defines | Typedefs | Functions

HeapQueueMgr.h File Reference


Detailed Description

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>
Version:
0.00.01
#include <ti/ipc/GateMP.h>
Include dependency graph for HeapQueueMgr.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 Documentation

#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 Documentation

typedef struct HeapQueueMgr_Object* HeapQueueMgr_Handle

HeapQueueMgr_Handle type.

Structure defining parameters for the HeapQueueMgr module.


Function Documentation

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.

Parameters:
handlePtrPointer to handle returned from HeapQueueMgr_open
See also:
HeapQueueMgr_open
HeapQueueMgr_Handle HeapQueueMgr_create ( const HeapQueueMgr_Params params )

Create a HeapQueueMgr instance.

Parameters:
paramsHeapQueueMgr parameters
Returns:
HeapQueueMgr Handle
Int HeapQueueMgr_delete ( HeapQueueMgr_Handle handlePtr )

Delete a created HeapQueueMgr instance.

Parameters:
handlePtrPointer 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.

Parameters:
nameName of created HeapQueueMgr instance
handlePtrPointer to HeapQueueMgr handle to be opened
Returns:
HeapQueueMgr status:
See also:
HeapQueueMgr_close
Void HeapQueueMgr_Params_init ( HeapQueueMgr_Params params )

Initialize a HeapQueueMgr parameters struct.

Parameters:
[out]paramsPointer 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.

  • If possible, allocate larger blocks first. Previous allocations of small memory blocks can reduce the size of the blocks available for larger memory allocations.
  • Realize that alloc() can fail even if the heap contains a sufficient absolute amount of unalloccated space. This is because the largest free memory block may be smaller than total amount of unallocated memory.
Parameters:
handleHandle to previously created/opened instance.
sizeSize to be allocated (in MADUs)
alignAlignment for allocation (power of 2)
See also:
HeapQueueMgr_free
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.

Parameters:
handleHandle to previously created/opened instance.
blockBlock of memory to be freed.
sizeSize to be freed (in MADUs)
See also:
HeapQueueMgr_alloc
Void HeapQueueMgr_getStats ( HeapQueueMgr_Handle  handle,
Ptr  stats 
)

Get memory statistics.

Parameters:
[in]handleHandle to previously created/opened instance.
[out]statsMemory statistics structure
See also:
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Defines

Copyright 2012, Texas Instruments Incorporated