Main Page | Alphabetical List | Data Structures | Directories | File List | Data Fields | Globals

IHeap.h File Reference


Detailed Description

Defines Heap based memory allocator.

Heap implementation that manages fixed size buffers that can be used in a multiprocessor system with shared memory.

The Heap manager provides functions to allocate and free storage from a heap of type Heap which inherits from IHeap. Heap manages a single fixed-size buffer, split into equally sized allocable blocks.

The Heap 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.

This module is instance based. Each instance requires shared memory (for the buffers and other internal state). This is specified via the sharedAddr parameter to the create. The proper sharedAddrSize parameter can be determined via the sharedMemReq call. Note: the parameters to this function must be the same that will used to create the instance.

The Heap module uses a NameServer instance to store instance information when an instance is created and the name parameter is non-NULL. If a name is supplied, it must be unique for all Heap instances.

The create initializes the shared memory as needed. The shared memory must be initialized to 0 before the Heap instance is created or opened.

Once an instance is created, an open can be performed. The open is used to gain access to the same Heap instance. Generally an instance is created on one processor and opened on the other processor(s).

The open returns a Heap instance handle like the create, however the open does not modify the shared memory.

There are two options when opening the instance: -Supply the same name as specified in the create. The Heap module queries the NameServer to get the needed information. -Supply the same sharedAddr value as specified in the create.

If the open is called before the instance is created, open returns NULL.

Constraints: -Align parameter must be a power of 2. -The buffer passed to dynamically create a Heap must be aligned according to the alignment parameter, and must be large enough to account for the actual block size after it has been rounded up to a multiple of the alignment.

02.00.00.68_beta1

============================================================================

Copyright (c) 2008-2009, Texas Instruments Incorporated

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

* Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.

* Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.

* Neither the name of Texas Instruments Incorporated nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. Contact information for paper mail: Texas Instruments Post Office Box 655303 Dallas, Texas 75265 Contact information: http://www-k.ext.ti.com/sc/technical-support/product-information-centers.htm? DCMP=TIHomeTracking&HQS=Other+OT+home_d_contact ============================================================================

Definition in file IHeap.h.

#include <ti/syslink/utils/MemoryDefs.h>
#include <ti/syslink/utils/Trace.h>

Include dependency graph for IHeap.h:

Go to the source code of this file.

Data Structures

struct  IHeap_Object_tag
 Structure for the Handle for the Heap. More...

Typedefs

typedef IHeap_Object_tag IHeap_Object
 Forward declaration of structure defining object for the Heap module.
typedef IHeap_ObjectIHeap_Handle
 Handle for the Heap Buf.
typedef Ptr(* IHeap_allocFxn )(IHeap_Handle handle, SizeT size, SizeT align)
 Type for function pointer to allocate a memory block.
typedef Void(* IHeap_freeFxn )(IHeap_Handle handle, Ptr block, SizeT size)
 Type for function pointer to free a memory block.
typedef Void(* IHeap_getStatsFxn )(IHeap_Handle handle, Memory_Stats *stats)
 Type for function pointer to get memory related statistics.
typedef Bool(* IHeap_isBlockingFxn )(IHeap_Handle handle)
typedef Ptr(* IHeap_getKnlHandleFxn )(IHeap_Handle handle)
 Type for function pointer to get handle to kernel object.

Functions

static Ptr IHeap_alloc (IHeap_Handle handle, SizeT size, SizeT align)
 Allocate a block of memory of specified size.
static Void IHeap_free (IHeap_Handle handle, Ptr block, SizeT size)
 Frees a block of memory.
static Void IHeap_getStats (IHeap_Handle handle, Memory_Stats *stats)
 Get memory statistics.
static Bool IHeap_isBlocking (IHeap_Handle handle)
 Indicate whether the heap may block during an alloc or free call.
static Ptr IHeap_getKnlHandle (IHeap_Handle handle)
 Function to get the kernel object pointer embedded in userspace heap. Some Heap implementations return the kernel object handle. Heaps which do not have kernel object pointer embedded return NULL.


Typedef Documentation

typedef Ptr(* IHeap_allocFxn)(IHeap_Handle handle, SizeT size, SizeT align)
 

Type for function pointer to allocate a memory block.

Definition at line 138 of file IHeap.h.

typedef Void(* IHeap_freeFxn)(IHeap_Handle handle, Ptr block, SizeT size)
 

Type for function pointer to free a memory block.

Definition at line 143 of file IHeap.h.

typedef Ptr(* IHeap_getKnlHandleFxn)(IHeap_Handle handle)
 

Type for function pointer to get handle to kernel object.

Definition at line 158 of file IHeap.h.

typedef Void(* IHeap_getStatsFxn)(IHeap_Handle handle, Memory_Stats *stats)
 

Type for function pointer to get memory related statistics.

Definition at line 148 of file IHeap.h.

typedef struct IHeap_Object* IHeap_Handle
 

Handle for the Heap Buf.

Definition at line 130 of file IHeap.h.

typedef Bool(* IHeap_isBlockingFxn)(IHeap_Handle handle)
 

Definition at line 155 of file IHeap.h.

typedef struct IHeap_Object_tag IHeap_Object
 

Forward declaration of structure defining object for the Heap module.

Definition at line 125 of file IHeap.h.


Function Documentation

static Ptr IHeap_alloc IHeap_Handle  handle,
SizeT  size,
SizeT  align
[inline, static]
 

Allocate a block of memory of specified size.

Parameters:
handle Handle to previously created/opened instance.
size Size to be allocated (in bytes)
align Alignment for allocation (power of 2)
Return values:
buffer Allocated buffer
See also:
IHeap_free

Definition at line 199 of file IHeap.h.

References GT_assert.

00202 {
00203     Ptr buffer;
00204 
00205     GT_assert (curTrace, (((IHeap_Object *) handle)->alloc != NULL));
00206     buffer = ((IHeap_Object *) handle)->alloc (handle, size, align);
00207     return (buffer);
00208 }

static Void IHeap_free IHeap_Handle  handle,
Ptr  block,
SizeT  size
[inline, static]
 

Frees a block of memory.

Parameters:
handle Handle to previously created/opened instance.
block Block of memory to be freed.
size Size to be freed (in bytes)
See also:
Heap_alloc

Definition at line 220 of file IHeap.h.

References GT_assert.

00223 {
00224     GT_assert (curTrace, (((IHeap_Object *) handle)->free != NULL));
00225     ((IHeap_Object *) handle)->free (handle, block, size);
00226 }

static Ptr IHeap_getKnlHandle IHeap_Handle  handle  )  [inline, static]
 

Function to get the kernel object pointer embedded in userspace heap. Some Heap implementations return the kernel object handle. Heaps which do not have kernel object pointer embedded return NULL.

handle handle to a heap instance

Return values:
handle Handle to kernel object.
See also:

Definition at line 275 of file IHeap.h.

References GT_assert.

00276 {
00277     Ptr knlHandle;
00278     GT_assert (curTrace, (((IHeap_Object *) handle)->getKnlHandle != NULL));
00279     knlHandle = ((IHeap_Object *) handle)->getKnlHandle (handle);
00280     return (knlHandle);
00281 }

static Void IHeap_getStats IHeap_Handle  handle,
Memory_Stats stats
[inline, static]
 

Get memory statistics.

Parameters:
handle Handle to previously created/opened instance. stats Memory statistics structure
See also:

Definition at line 237 of file IHeap.h.

References GT_assert.

00239 {
00240     GT_assert (curTrace, (((IHeap_Object *) handle)->getStats != NULL));
00241     ((IHeap_Object *) handle)->getStats (handle, stats);
00242 }

static Bool IHeap_isBlocking IHeap_Handle  handle  )  [inline, static]
 

Indicate whether the heap may block during an alloc or free call.

Parameters:
handle Handle to previously created/opened instance.
Return values:
TRUE Heap is blocking
FALSE Heap is non-blocking
See also:

Definition at line 255 of file IHeap.h.

References GT_assert.

00256 {
00257     Bool isBlocking;
00258     GT_assert (curTrace, (((IHeap_Object *) handle)->isBlocking != NULL));
00259     isBlocking = ((IHeap_Object *) handle)->isBlocking (handle);
00260     return (isBlocking);
00261 }


Generated on Mon Mar 14 11:59:47 2011 for Syslink by  doxygen 1.4.4