#include <PsnMemoryManager.h>
Inheritance diagram for PsnMemoryManager:

Public Methods | |
| virtual | ~PsnMemoryManager () |
| destructor | |
| PsnMemoryManager () | |
| constructor | |
| void | init () |
| declare the memory manager to the memory management subsystem. | |
| virtual void * | allocateSizeRemembered (size_t size)=0 |
| alloc a memory zone that can be correctly freed by calling freeSizeRemembered with the resulting pointer | |
| virtual void | freeSizeRemembered (void *ptr)=0 |
| free a memory zone allocated with allocateSizeRemembered | |
| virtual bool | inAdressSpace (void *ptr) const=0 |
| find out if a given adress is managed by the current memory manager | |
Static Public Methods | |
| PsnMemoryManager * | whichMemoryManager (void *) |
| Find which was the first memory manager to declare managing memory at a given adress. | |
Static Protected Methods | |
| list< PsnMemoryManager * > * | getListOfMemoryManagers () |
| the list of memory managers created in the current address space | |
| PsnMutexLock * | getGlobalListMutex () |
| the lock to protect access to the global list of memory managers | |
Protected Attributes | |
| bool | _isInitialized |
| isInitialized. | |
Definition at line 33 of file PsnMemoryManager.h.
|
|
destructor
Definition at line 67 of file PsnMemoryManager.cxx. References getGlobalListMutex(), getListOfMemoryManagers(), HeapStackTop::globalMemoryManagerKey, PsnMutexLock::protect(), and PsnMutexLock::unprotect().
00068 {
00069 // do the test, because removal of elements not present seem to bug some implementatiosn of the standard library
00070 if (_isInitialized)
00071 {
00072 getGlobalListMutex()->protect();
00073 getListOfMemoryManagers()->remove( this ) ;
00074 getGlobalListMutex()->unprotect() ;
00075 }
00076
00077 //when killing the last memory manager, some precautions have to be taken
00078 if ( this == pthread_getspecific( HeapStackTop::globalMemoryManagerKey ) )
00079 {
00080 pthread_setspecific ( HeapStackTop::globalMemoryManagerKey , NULL );
00081 }
00082 }
|
|
|
constructor
Definition at line 84 of file PsnMemoryManager.cxx.
00084 : 00085 _isInitialized ( false ) 00086 { 00087 } |
|
|
alloc a memory zone that can be correctly freed by calling freeSizeRemembered with the resulting pointer
Implemented in PsnDescriptorMemoryManager, PsnRelaxedMemoryManager, PsnSharedMemoryManager, PsnSystemMemoryManager, and PsnThreadMemoryManager. Referenced by PsnMultiThreadedScheduler::_threadContainer(), PsnMultiThreadedBenchmarkingScheduler::_threadContainer(), PsnThreadMemoryManager::allocateSizeRemembered(), PsnDescriptorMemoryManager::allocateSizeRemembered(), PsnMemoryElementDescriptor::operator new(), PsnDescriptorMemoryManager::PsnDescriptorMemoryManager(), and PsMultiThreadedController::run(). |
|
|
free a memory zone allocated with allocateSizeRemembered
Implemented in PsnDescriptorMemoryManager, PsnRelaxedMemoryManager, PsnSharedMemoryManager, PsnSystemMemoryManager, and PsnThreadMemoryManager. Referenced by PsnThreadMemoryManager::freeLeakedMemoryBlocks(), PsnThreadMemoryManager::freeSizeRemembered(), PsnSystemMemoryManager::freeSizeRemembered(), PsnSharedMemoryManager::freeSizeRemembered(), operator delete(), and PsnMemoryElementDescriptor::operator delete(). |
|
|
the lock to protect access to the global list of memory managers
Definition at line 30 of file PsnMemoryManager.cxx. Referenced by init(), whichMemoryManager(), and ~PsnMemoryManager().
00031 {
00032 static PsnMutexLock toto ;
00033 return & toto ;
00034 }
|
|
|
the list of memory managers created in the current address space
Definition at line 24 of file PsnMemoryManager.cxx. Referenced by init(), whichMemoryManager(), and ~PsnMemoryManager().
00025 {
00026 static list <PsnMemoryManager *> designPattern ;
00027 return & designPattern ;
00028 }
|
|
|
find out if a given adress is managed by the current memory manager
Implemented in PsnDescriptorMemoryManager, PsnSharedMemoryManager, PsnSystemMemoryManager, and PsnThreadMemoryManager. Referenced by PsnThreadMemoryManager::freeSizeRemembered(). |
|
|
declare the memory manager to the memory management subsystem. This declaration cannot be made in the constructor, because in multi-threaded environments, it would enable the memory management subsystem to try and use a memory manager still under construction. Definition at line 89 of file PsnMemoryManager.cxx. References _isInitialized, getGlobalListMutex(), getListOfMemoryManagers(), PsnMutexLock::protect(), and PsnMutexLock::unprotect(). Referenced by PsnMultiThreadedScheduler::_threadContainer(), PsnMultiThreadedBenchmarkingScheduler::_threadContainer(), and PsMultiThreadedController::run().
00090 {
00091 getGlobalListMutex()->protect();
00092 getListOfMemoryManagers()->push_back( this ) ;
00093 getGlobalListMutex()->unprotect() ;
00094 _isInitialized = true ;
00095 }
|
|
|
Find which was the first memory manager to declare managing memory at a given adress.
Definition at line 37 of file PsnMemoryManager.cxx. References getGlobalListMutex(), getListOfMemoryManagers(), HeapStackTop::getSystemMemoryManager(), PsnMutexLock::protect(), and PsnMutexLock::unprotect(). Referenced by PsnThreadMemoryManager::freeLeakedMemoryBlocks(), PsnSystemMemoryManager::freeSizeRemembered(), PsnSharedMemoryManager::freeSizeRemembered(), PsnMomeArray< T >::operator delete(), PsnMomeReaderFifo< Type >::printDebuggingInformation(), and PsnMomeArray< T >::~PsnMomeArray().
00038 {
00039 PsnMemoryManager * result = NULL ;
00040 getGlobalListMutex()->protect();
00041 //cerr<<"PsnMemoryManager::whichMemoryManager : getGlobalListMutex()->protect();"<<endl;
00042 list <PsnMemoryManager *>::iterator i = getListOfMemoryManagers()->begin() ;
00043 while ( (result == NULL ) && (i != getListOfMemoryManagers()->end() ))
00044 {
00045 #ifdef _DEBUGMEMORYMANAGEMENT
00046 assert ( (*i)->_isInitialized ) ;
00047 #endif
00048 if ( (*i)->inAdressSpace (ptr) )
00049 {
00050 result = *i ;
00051 }
00052 else
00053 {
00054 ++i ;
00055 }
00056 }
00057 getGlobalListMutex()->unprotect();
00058 if ( result == NULL)
00059 {
00060 result = HeapStackTop::getSystemMemoryManager() ;
00061 }
00062
00063 return result ;
00064 }
|
|
|
isInitialized. when the _DEBUGMEMORYMANAGEMENT compilation flag is set, is tested by the memory management subsystem to make sure init was called Definition at line 62 of file PsnMemoryManager.h. Referenced by init(). |
| Documentation generated on Mon Nov 25 15:26:08 2002 |
Generated with doxygen 1.2.12 by Dimitri van Heesch , 1997-2001 |