00001 /* 00002 * This file is part of openMask © INRIA, CNRS, Universite de Rennes 1 1993-2002, thereinafter the Software 00003 * 00004 * The Software has been developped within the Siames Project. 00005 * INRIA, the University of Rennes 1 and CNRS jointly hold intellectual property rights 00006 * 00007 * The Software has been registered with the Agence pour la Protection des 00008 * Programmes (APP) under registration number IDDN.FR.001.510008.00.S.P.2001.000.41200 00009 * 00010 * This file may be distributed under the terms of the Q Public License 00011 * version 1.0 as defined by Trolltech AS of Norway and appearing in the file 00012 * LICENSE.QPL included in the packaging of this file. 00013 * 00014 * Licensees holding valid specific licenses issued by INRIA, CNRS or Université de Rennes 1 00015 * for the software may use this file in accordance with that specific license 00016 * 00017 */ 00018 #if defined (_MOME) && !defined (_OLDALLOCATORS) 00019 #include <PsnUniqueCreator.h> 00020 #include <MomeDsm.h> 00021 #include <mySharedAllocator.h> 00022 #include <PsNomSymServer.h> 00023 #include <PsnOutputOffsetTable.h> 00024 #include <PsnBroadcastManager.h> 00025 #include "PsnLock.h" 00026 00027 PsnUniqueCreator::PsnUniqueCreator(PsnCoherantMemoryManager * memoryManager) 00028 : _myDataMemoryManager(memoryManager) { 00029 //si l'assertion là est fausse, il faut changer dans le .h le nombre de tables prévue pour lebroadcastmanager 00030 assert(2*PsnBroadcastManager::nbTablesDansBuffer==6); 00031 _mySharedData= newPsnUniqueCreatorData(); 00032 } 00033 00034 PsnUniqueCreatorData * PsnUniqueCreator::newPsnUniqueCreatorData() { 00035 if(MomeMe==0) { 00036 _mySharedData = new(_myDataMemoryManager) PsnUniqueCreatorData(); 00037 } 00038 else { 00039 _mySharedData=(PsnUniqueCreatorData * )_myDataMemoryManager->localAddressToGlobal(_myDataMemoryManager->uniqueCreatorDataOffset); 00040 } 00041 return _mySharedData; 00042 } 00043 //La version selon la norme ! 00044 // PsNomSymServerMome * PsnUniqueCreator::newPsNomSymServer(int i) { 00045 // PsNomSymServerMome * result; 00046 // if(MomeMe==0) { 00047 // const PsNomSymServerT<STL_ALLOC> & ancServeur(*((PsNomSymServerT<STL_ALLOC> *)PsNomSym::serveurDeNom)); 00048 // result = new PsNomSymServerT<mySharedAllocatorT>(i); 00049 // *result = ancServeur; 00050 // if(*result==*PsNomSym::serveurDeNom) { 00051 // cout<<"Conversion réussie"<<endl; 00052 // } 00053 // else { 00054 // PsnControleur::error("PsnUniqueCreator::newPsNomSymServer : pb de conversion de PsNomSymServer"); 00055 // } 00056 // _mySharedData->myNameServer=_myDataMemoryManager->globalAddressToLocal(result); 00057 // MomeBarrier(); 00058 // } 00059 // else { 00060 // MomeBarrier(); 00061 // result=(PsNomSymServerT<mySharedAllocatorT> *)_myDataMemoryManager->localAddressToGlobal(_mySharedData->myNameServer); 00062 // } 00063 // return result; 00064 // } 00065 00066 //La version qui compile 00067 PsNomSymServerMome * PsnUniqueCreator::newPsNomSymServer(int i) { 00068 PsNomSymServerMome * result; 00069 if(MomeMe==0) { 00070 const PsNomSymServerClassique & ancServeur(*((PsNomSymServerClassique *)PsNomSym::serveurDeNom)); 00071 result = new PsNomSymServerMome(ancServeur.getCanonicalRepresentation() ); 00072 if(*result==*PsNomSym::serveurDeNom) { 00073 cout<<"Conversion réussie"<<endl; 00074 } 00075 else { 00076 PsnControleur::error("PsnUniqueCreator::newPsNomSymServer : pb de conversion de PsNomSymServer"); 00077 } 00078 _mySharedData->myNameServer=_myDataMemoryManager->globalAddressToLocal(result); 00079 } 00080 else { 00081 //because new results in the creation of a lock, create à false one 00082 PsnLock * unImportant = new PsnLock() ; 00083 result=(PsNomSymServerMome *)_myDataMemoryManager->localAddressToGlobal(_mySharedData->myNameServer); 00084 } 00085 return result; 00086 } 00087 00088 00089 void * PsnUniqueCreatorData::operator new(size_t size, const PsnCoherantMemoryManager * aMemoryManager) { 00090 return aMemoryManager->localAddressToGlobal(aMemoryManager->uniqueCreatorDataOffset); 00091 } 00092 00093 PsnOutputOffsetTable * PsnUniqueCreator::newPsnOutputOffsetTable() { 00094 PsnOutputOffsetTable * result; 00095 if(MomeMe==0) { 00096 result = new PsnOutputOffsetTable(); 00097 _mySharedData->_myOutputServer=_myDataMemoryManager->globalAddressToLocal(result); 00098 } 00099 else { 00100 //because new results in the creation of a lock, create à false one 00101 PsnLock * unImportant = new PsnLock() ; 00102 result=(PsnOutputOffsetTable *)_myDataMemoryManager->localAddressToGlobal(_mySharedData->_myOutputServer); 00103 } 00104 return result; 00105 } 00106 00107 PsnBroadcastManager::_myTypeOfTable * PsnUniqueCreator::newbroadcastManagerTable(int i) { 00108 PsnBroadcastManager::_myTypeOfTable * resul; 00109 if(MomeMe==0) { 00110 //install our memory manager as the default memory manager 00111 HeapStackTop toto(_myDataMemoryManager); 00112 resul = new PsnBroadcastManager::_myTypeOfTable(); 00113 #ifdef _DEBUGEVT 00114 cerr<<"PsnUniqueCreator::newbroadcastManagerTable"<<resul<<endl; 00115 #endif 00116 _mySharedData->_broadcastManagerTables[i]=_myDataMemoryManager->globalAddressToLocal(resul); 00117 } 00118 else { 00119 resul=(PsnBroadcastManager::_myTypeOfTable *)_myDataMemoryManager->localAddressToGlobal(_mySharedData->_broadcastManagerTables[i]); 00120 } 00121 return resul; 00122 } 00123 00124 // PsnMomeWeakMemoryManager::coheranceType * PsnUniqueCreator::newcoheranceType(int size) { 00125 // PsnMomeWeakMemoryManager::coheranceType * resul; 00126 // if(MomeMe==0) { 00127 // //install our memory manager as the default memory manager 00128 // HeapStackTop toto(_myDataMemoryManager); 00129 // resul = new PsnMomeWeakMemoryManager::coheranceType[ size ] ; 00130 // _mySharedData->_coheranceTable = _myDataMemoryManager->globalAddressToLocal( resul ); 00131 // } 00132 // else { 00133 // resul = ( PsnMomeWeakMemoryManager::coheranceType * )_myDataMemoryManager->localAddressToGlobal(_mySharedData->_coheranceTable ); 00134 // } 00135 // return resul; 00136 // } 00137 00138 00139 PsnRelaxedMemoryManager::PageState * PsnUniqueCreator::newPageStateTable( int size ) { 00140 _myDataMemoryManager->lockIfNeeded(); 00141 PsnRelaxedMemoryManager::PageState * resul; 00142 if(_mySharedData->_numberOfPageStateTable == 0) { 00143 //install our memory manager as the default memory manager 00144 HeapStackTop toto(_myDataMemoryManager); 00145 resul = new PsnRelaxedMemoryManager::PageState [ size ] ; 00146 _mySharedData->_coheranceTable = _myDataMemoryManager->globalAddressToLocal( resul ); 00147 for (int i = 0; i<size ; i++) { 00148 resul[i] = PsnRelaxedMemoryManager::Free ; 00149 } 00150 } 00151 else { 00152 resul = ( PsnRelaxedMemoryManager::PageState * )_myDataMemoryManager->localAddressToGlobal(_mySharedData->_coheranceTable ); 00153 } 00154 // 00155 ++(_mySharedData->_numberOfPageStateTable) ; 00156 _myDataMemoryManager->unlockIfNeeded() ; 00157 return resul; 00158 } 00159 00160 void PsnUniqueCreator::deletePageStateTable ( int size ) { 00161 _myDataMemoryManager->lockIfNeeded() ; 00162 --(_mySharedData->_numberOfPageStateTable) ; 00163 if(_mySharedData->_numberOfPageStateTable == 0) { 00164 delete[] (PsnRelaxedMemoryManager::PageState *) _myDataMemoryManager -> localAddressToGlobal(_mySharedData->_coheranceTable ); 00165 } 00166 _myDataMemoryManager->unlockIfNeeded() ; 00167 } 00168 00169 00170 int * PsnUniqueCreator::newWhenSyncedTable( int size ) { 00171 _myDataMemoryManager->lockIfNeeded(); 00172 int * resul; 00173 if(_mySharedData->_numberOfWhenSyncedTable == 0) { 00174 //install our memory manager as the default memory manager 00175 HeapStackTop toto(_myDataMemoryManager); 00176 resul = new int [ size ] ; 00177 _mySharedData->_whenSyncedTable = _myDataMemoryManager->globalAddressToLocal( resul ); 00178 for (int i = 0; i<size ; i++) { 00179 resul[i] = 0 ; 00180 } 00181 } 00182 else { 00183 resul = ( int * )_myDataMemoryManager->localAddressToGlobal(_mySharedData->_whenSyncedTable ); 00184 } 00185 // 00186 ++(_mySharedData->_numberOfWhenSyncedTable) ; 00187 _myDataMemoryManager->unlockIfNeeded() ; 00188 return resul; 00189 } 00190 00191 void PsnUniqueCreator::deleteWhenSyncedTable ( int size ) { 00192 _myDataMemoryManager->lockIfNeeded() ; 00193 --(_mySharedData->_numberOfWhenSyncedTable) ; 00194 if(_mySharedData->_numberOfWhenSyncedTable == 0) { 00195 delete[] (int *) _myDataMemoryManager -> localAddressToGlobal(_mySharedData->_whenSyncedTable ); 00196 } 00197 _myDataMemoryManager->unlockIfNeeded() ; 00198 } 00199 00200 #endif 00201 00202 00203 00204 00205
| Documentation generated on Mon Nov 25 15:25:01 2002 |
Generated with doxygen 1.2.12 by Dimitri van Heesch , 1997-2001 |