Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members  

PsnSharedArrayMemoryManager Class Reference

a memory manager class where memory is allocated at the same offset in a certain number of nearly contiguous memory pages. More...

#include <PsnSharedArrayMemoryManager.h>

Inheritance diagram for PsnSharedArrayMemoryManager:

Inheritance graph
[legend]
Collaboration diagram for PsnSharedArrayMemoryManager:

Collaboration graph
[legend]
List of all members.

Public Methods

 PsnSharedArrayMemoryManager (size_t sizeDsm, size_t pageSize, size_t alignedSize, PsnRelaxedMemoryManager &memoryManager, int queueSize)
 the constructor

virtual ~PsnSharedArrayMemoryManager ()
 the destructor

virtual void * mmalloc (size_t size)
 allocate memory from this memory manager

virtual void mfree (void *ptr, size_t size)
 free allocated memory

virtual size_t getStepSize ()
 get the dtep between consecutive element of the array managed


Protected Attributes

PsnMemoryElementDescriptor_freeMem
size_t _sizeLeft
const size_t _stepSize
 the step between different elements of the array


Detailed Description

a memory manager class where memory is allocated at the same offset in a certain number of nearly contiguous memory pages.

Definition at line 25 of file PsnSharedArrayMemoryManager.h.


Constructor & Destructor Documentation

PsnSharedArrayMemoryManager::PsnSharedArrayMemoryManager size_t    sizeDsm,
size_t    pageSize,
size_t    alignedSize,
PsnRelaxedMemoryManager   memoryManager,
int    queueSize
 

the constructor

Definition at line 22 of file PsnSharedArrayMemoryManager.cxx.

References PsnFramedMemoryManager::_blockSize, _freeMem, PsnFramedMemoryManager::_queueSize, PsnFramedMemoryManager::addBlockInSync(), PsnMemoryElementDescriptor::base, PsnMemoryElementDescriptor::next, and PsnMemoryElementDescriptor::size.

00022                                                                                                                                                                     :
00023    PsnFramedMemoryManager(sizeDsm * queueSize,
00024                           pageSize, 
00025                           alignedSize, 
00026                           memoryManager, 
00027                           queueSize),
00028    _stepSize(sizeDsm) 
00029 {
00030    _freeMem = new PsnMemoryElementDescriptor() ;
00031    _freeMem->base = 0 ;
00032    _freeMem->next = (unsigned int) NULL ;
00033    _freeMem->size = _blockSize ;
00034 
00035    //here, we place a little shortcut for easy allocation and deallocation : we suppose a PsnSharedArrayMemoryManager has a _blockSize comprised of very little pages (often 1) and that allocation in these pages takes place immediatly after creation.
00036    for (int i = _queueSize - 1 ; i >= 0 ; i-- ) {//in reverse order because of the underlying set
00037       addBlockInSync( i );
00038    }
00039 }

PsnSharedArrayMemoryManager::~PsnSharedArrayMemoryManager   [virtual]
 

the destructor

Definition at line 41 of file PsnSharedArrayMemoryManager.cxx.

References PsnFramedMemoryManager::_blockSize, _freeMem, and PsnMemoryElementDescriptor::size.

00041                                                           {
00042    assert (_freeMem->size == _blockSize ) ;
00043    delete _freeMem ;
00044 }


Member Function Documentation

size_t PsnSharedArrayMemoryManager::getStepSize   [virtual]
 

get the dtep between consecutive element of the array managed

Definition at line 64 of file PsnSharedArrayMemoryManager.cxx.

References _stepSize.

Referenced by PsnRelaxedMemoryManager::mmallocInPages().

00064                                                 {
00065    return _stepSize ;
00066 }

void PsnSharedArrayMemoryManager::mfree void *    ptr,
size_t    size
[virtual]
 

free allocated memory

Reimplemented from PsnSharedMemoryManager.

Definition at line 58 of file PsnSharedArrayMemoryManager.cxx.

References _freeMem, _sizeLeft, PsnSecondarySharedMemoryManager::addInThisFree(), and PsnSharedMemoryManager::globalAddressToLocal().

00058                                                                   {
00059    addInThisFree ( & _freeMem , globalAddressToLocal(ptr), size ) ;
00060    _sizeLeft += size ;
00061 }

void * PsnSharedArrayMemoryManager::mmalloc size_t    size [virtual]
 

allocate memory from this memory manager

Reimplemented from PsnSharedMemoryManager.

Definition at line 46 of file PsnSharedArrayMemoryManager.cxx.

References _freeMem, _sizeLeft, and PsnSecondarySharedMemoryManager::getFromThisFree().

Referenced by PsnRelaxedMemoryManager::mmallocInPages().

00046                                                          {
00047 #ifdef _DEBUGALLOCATIONMOME
00048    cerr<<"PsnSharedArrayMemoryManager::mmalloc "<<size<<" "<<& _freeMem<<" ";
00049 #endif
00050    void * resul = getFromThisFree( & _freeMem , size) ;
00051 #ifdef _DEBUGALLOCATIONMOME
00052    cerr<<resul<<endl;;
00053 #endif
00054    if (resul != NULL) _sizeLeft -= size ;
00055    return resul ;
00056 }


Member Data Documentation

PsnMemoryElementDescriptor* PsnSharedArrayMemoryManager::_freeMem [protected]
 

Definition at line 44 of file PsnSharedArrayMemoryManager.h.

Referenced by mfree(), mmalloc(), PsnSharedArrayMemoryManager(), and ~PsnSharedArrayMemoryManager().

size_t PsnSharedArrayMemoryManager::_sizeLeft [protected]
 

Definition at line 47 of file PsnSharedArrayMemoryManager.h.

Referenced by mfree(), and mmalloc().

const size_t PsnSharedArrayMemoryManager::_stepSize [protected]
 

the step between different elements of the array

Definition at line 50 of file PsnSharedArrayMemoryManager.h.

Referenced by getStepSize().


The documentation for this class was generated from the following files:
logo OpenMask

Documentation generated on Mon Nov 25 15:26:29 2002

Generated with doxygen 1.2.12 by Dimitri van Heesch ,   1997-2001