Index: XIOS3/trunk/src/manager/contexts_manager.cpp
===================================================================
--- XIOS3/trunk/src/manager/contexts_manager.cpp	(revision 2514)
+++ XIOS3/trunk/src/manager/contexts_manager.cpp	(revision 2517)
@@ -27,11 +27,10 @@
     MPI_Comm_rank(xiosComm_, &commRank) ;
     winNotify_ = new CWindowManager(xiosComm_, maxBufferSize_) ;
+    winNotify_->updateToExclusiveWindow(commRank, this, &CContextsManager::notificationsDumpOut) ;
    
 
     winContexts_ = new CWindowManager(xiosComm_, maxBufferSize_) ;
-    winContexts_->lockWindow(commRank,0) ;
-    winContexts_->updateToWindow(commRank, this, &CContextsManager::contextsDumpOut) ;
-    winContexts_->unlockWindow(commRank,0) ;
-
+    winContexts_->updateToExclusiveWindow(commRank, this, &CContextsManager::contextsDumpOut) ;
+  
     MPI_Barrier(xiosComm_)  ;    
   }
@@ -111,5 +110,5 @@
     winNotify_->lockWindowExclusive(rank) ;
     winNotify_->pushToLockedWindow(rank, this, &CContextsManager::notificationsDumpOut) ;
-    winNotify_->unlockWindow(rank) ;
+    winNotify_->unlockWindowExclusive(rank) ;
   }
 
@@ -170,7 +169,5 @@
     int commRank ;
     MPI_Comm_rank(xiosComm_, &commRank) ;
-    winNotify_->lockWindowExclusive(commRank) ;
-    winNotify_->popFromLockedWindow(commRank, this, &CContextsManager::notificationsDumpIn) ;
-    winNotify_->unlockWindow(commRank) ;
+    winNotify_->popFromExclusiveWindow(commRank, this, &CContextsManager::notificationsDumpIn) ;
     if (notifyType_==NOTIFY_CREATE_CONTEXT) createServerContext() ;
     else if (notifyType_==NOTIFY_CREATE_INTERCOMM) createServerContextIntercomm() ;
@@ -215,5 +212,5 @@
     contexts_[fullContextId] = contextInfo ;
     winContexts_->updateToLockedWindow(managerGlobalLeader_, this, &CContextsManager::contextsDumpOut) ;
-    winContexts_->unlockWindow(managerGlobalLeader_) ;
+    winContexts_->unlockWindowExclusive(managerGlobalLeader_) ;
   }
 
@@ -227,7 +224,5 @@
     {
 
-      winContexts_->lockWindowShared(managerGlobalLeader_) ;
-      winContexts_->updateFromLockedWindow(managerGlobalLeader_, this, &CContextsManager::contextsDumpIn) ;
-      winContexts_->unlockWindow(managerGlobalLeader_) ;
+      winContexts_->updateFromSharedWindow(managerGlobalLeader_, this, &CContextsManager::contextsDumpIn) ;
 
       auto it=contexts_.find(fullContextId) ;
Index: XIOS3/trunk/src/manager/coupler_manager.cpp
===================================================================
--- XIOS3/trunk/src/manager/coupler_manager.cpp	(revision 2514)
+++ XIOS3/trunk/src/manager/coupler_manager.cpp	(revision 2517)
@@ -23,11 +23,6 @@
     if (commRank==managerGlobalLeader_)
     {
-      winRegistredCoupling_->lockWindow(managerGlobalLeader_,0) ;
-      winRegistredCoupling_->updateToWindow(managerGlobalLeader_, this, &CCouplerManager::registredCouplingDumpOut) ;
-      winRegistredCoupling_->unlockWindow(managerGlobalLeader_,0) ;
-
-      winNextCoupling_->lockWindow(managerGlobalLeader_,0) ;
-      winNextCoupling_->updateToWindow(managerGlobalLeader_, this, &CCouplerManager::nextCouplingDumpOut) ;
-      winNextCoupling_->unlockWindow(managerGlobalLeader_,0) ;
+      winRegistredCoupling_->updateToExclusiveWindow(managerGlobalLeader_, this, &CCouplerManager::registredCouplingDumpOut) ;
+      winNextCoupling_->updateToExclusiveWindow(managerGlobalLeader_, this, &CCouplerManager::nextCouplingDumpOut) ;
     }
 
@@ -47,22 +42,22 @@
     size_t key = strHash(getStrCoupling(srcCoupling,dstCoupling)) ;
     
-    winRegistredCoupling_->lockWindow(managerGlobalLeader_,0) ;
-    winRegistredCoupling_->updateFromWindow(managerGlobalLeader_, this, &CCouplerManager::registredCouplingDumpIn) ;
+    winRegistredCoupling_->lockWindowExclusive(managerGlobalLeader_) ;
+    winRegistredCoupling_->updateFromLockedWindow(managerGlobalLeader_, this, &CCouplerManager::registredCouplingDumpIn) ;
     if (registredCoupling_.count(key)==1)
     {
       registredCoupling_.erase(key) ;
-      winRegistredCoupling_->updateToWindow(managerGlobalLeader_, this, &CCouplerManager::registredCouplingDumpOut) ;
-      winNextCoupling_->lockWindow(managerGlobalLeader_,0) ;
-      winNextCoupling_->updateFromWindow(managerGlobalLeader_, this, &CCouplerManager::nextCouplingDumpIn) ;
+      winRegistredCoupling_->updateToLockedWindow(managerGlobalLeader_, this, &CCouplerManager::registredCouplingDumpOut) ;
+      winNextCoupling_->lockWindowExclusive(managerGlobalLeader_) ;
+      winNextCoupling_->updateFromLockedWindow(managerGlobalLeader_, this, &CCouplerManager::nextCouplingDumpIn) ;
       nextCoupling_.push_back(pair<size_t,int>(key,2)) ;
-      winNextCoupling_->updateToWindow(managerGlobalLeader_, this, &CCouplerManager::nextCouplingDumpOut) ;
-      winNextCoupling_->unlockWindow(managerGlobalLeader_,0) ;
+      winNextCoupling_->updateToLockedWindow(managerGlobalLeader_, this, &CCouplerManager::nextCouplingDumpOut) ;
+      winNextCoupling_->unlockWindowExclusive(managerGlobalLeader_) ;
     }
     else 
     {
       registredCoupling_.insert(key) ;
-      winRegistredCoupling_->updateToWindow(managerGlobalLeader_, this, &CCouplerManager::registredCouplingDumpOut) ;
+      winRegistredCoupling_->updateToLockedWindow(managerGlobalLeader_, this, &CCouplerManager::registredCouplingDumpOut) ;
     }
-    winRegistredCoupling_->unlockWindow(managerGlobalLeader_,0) ;
+    winRegistredCoupling_->unlockWindowExclusive(managerGlobalLeader_) ;
   }
 
@@ -73,6 +68,6 @@
     size_t key = strHash(getStrCoupling(srcCoupling,dstCoupling)) ;
 
-    winNextCoupling_->lockWindow(managerGlobalLeader_,0) ;
-    winNextCoupling_->updateFromWindow(managerGlobalLeader_, this, &CCouplerManager::nextCouplingDumpIn) ;
+    winNextCoupling_->lockWindowExclusive(managerGlobalLeader_) ;
+    winNextCoupling_->updateFromLockedWindow(managerGlobalLeader_, this, &CCouplerManager::nextCouplingDumpIn) ;
     if (nextCoupling_.front().first==key)
     {
@@ -80,8 +75,8 @@
       if (nextCoupling_.front().second==1) nextCoupling_.pop_front() ;
       else nextCoupling_.front().second=1 ;
-      winNextCoupling_->updateToWindow(managerGlobalLeader_, this, &CCouplerManager::nextCouplingDumpOut) ;
+      winNextCoupling_->updateToLockedWindow(managerGlobalLeader_, this, &CCouplerManager::nextCouplingDumpOut) ;
     }
     else ret=false ;
-    winNextCoupling_->unlockWindow(managerGlobalLeader_,0) ;
+    winNextCoupling_->unlockWindowExclusive(managerGlobalLeader_) ;
     return ret ;
   }
Index: XIOS3/trunk/src/manager/pool_ressource.cpp
===================================================================
--- XIOS3/trunk/src/manager/pool_ressource.cpp	(revision 2514)
+++ XIOS3/trunk/src/manager/pool_ressource.cpp	(revision 2517)
@@ -27,7 +27,5 @@
     
     notifyType_=NOTIFY_NOTHING;
-    winNotify_->lockWindow(commRank,0) ;
-    winNotify_->updateToWindow(commRank, this, &CPoolRessource::notificationsDumpOut) ;
-    winNotify_->unlockWindow(commRank,0) ;       
+    winNotify_->updateToExclusiveWindow(commRank, this, &CPoolRessource::notificationsDumpOut) ;
     MPI_Barrier(poolComm_) ;
   }
@@ -104,7 +102,5 @@
   void CPoolRessource::sendNotification(int rank)
   {
-    winNotify_->lockWindowExclusive(rank) ;
-    winNotify_->pushToLockedWindow(rank, this, &CPoolRessource::notificationsDumpOut) ;
-    winNotify_->unlockWindow(rank) ;
+    winNotify_->pushToExclusiveWindow(rank, this, &CPoolRessource::notificationsDumpOut) ;
   }
 
@@ -113,7 +109,5 @@
     int commRank ;
     MPI_Comm_rank(poolComm_, &commRank) ;
-    winNotify_->lockWindowExclusive(commRank) ;
-    winNotify_->popFromLockedWindow(commRank, this, &CPoolRessource::notificationsDumpIn) ;
-    winNotify_->unlockWindow(commRank) ;
+    winNotify_->popFromExclusiveWindow(commRank, this, &CPoolRessource::notificationsDumpIn) ;
     if (notifyType_==NOTIFY_CREATE_SERVICE) createService() ;
     else if (notifyType_==NOTIFY_CREATE_SERVICE_ONTO) createServiceOnto() ;
Index: XIOS3/trunk/src/manager/ressources_manager.cpp
===================================================================
--- XIOS3/trunk/src/manager/ressources_manager.cpp	(revision 2514)
+++ XIOS3/trunk/src/manager/ressources_manager.cpp	(revision 2517)
@@ -49,8 +49,6 @@
     info(40)<<"CRessourcesManager::createPool : calling createPool : "<<poolId<<"  of size"<<size<<endl ;
     info(40)<<"send notification to leader : "<<serverLeader_<<endl ;
-    winRessources_->lockWindow(managerGlobalLeader_,0) ;
-    winRessources_->updateFromWindow(managerGlobalLeader_, this, &CRessourcesManager::ressourcesDumpIn) ;
-    winRessources_->unlockWindow(managerGlobalLeader_,0) ;    
-   
+    winRessources_->updateFromExclusiveWindow(managerGlobalLeader_, this, &CRessourcesManager::ressourcesDumpIn) ;
+    
     notifyType_=NOTIFY_CREATE_POOL ;
     notifyCreatePool_=make_tuple(poolId, size) ;
@@ -61,7 +59,5 @@
   void CRessourcesManager::finalize(void)
   {
-    winRessources_->lockWindow(managerGlobalLeader_,0) ;
-    winRessources_->updateFromWindow(managerGlobalLeader_, this, &CRessourcesManager::ressourcesDumpIn) ;
-    winRessources_->unlockWindow(managerGlobalLeader_,0) ;    
+    winRessources_->updateFromExclusiveWindow(managerGlobalLeader_, this, &CRessourcesManager::ressourcesDumpIn) ;
    
     if (serverLeader_!=-1)
@@ -77,5 +73,5 @@
     winNotify_->lockWindowExclusive(rank) ;
     winNotify_->pushToLockedWindow(rank, this, &CRessourcesManager::notificationsDumpOut) ;
-    winNotify_->unlockWindow(rank) ;
+    winNotify_->unlockWindowExclusive(rank) ;
   }
 
@@ -139,5 +135,5 @@
     CTimer::get("CRessourcesManager::checkNotifications pop").suspend();
     CTimer::get("CRessourcesManager::checkNotifications unlock").resume();
-    winNotify_->unlockWindow(commRank) ;
+    winNotify_->unlockWindowExclusive(commRank) ;
     CTimer::get("CRessourcesManager::checkNotifications unlock").suspend();
     if (notifyType_==NOTIFY_CREATE_POOL) createPool() ;
@@ -196,19 +192,19 @@
   void CRessourcesManager::registerServerLeader(int serverLeaderRank)
   {
-    winRessources_->lockWindow(managerGlobalLeader_,0) ;
-    winRessources_->updateFromWindow(managerGlobalLeader_, this, &CRessourcesManager::ressourcesDumpIn) ;
+    winRessources_->lockWindowExclusive(managerGlobalLeader_) ;
+    winRessources_->updateFromLockedWindow(managerGlobalLeader_, this, &CRessourcesManager::ressourcesDumpIn) ;
     serverLeader_ = serverLeaderRank ;
-    winRessources_->updateToWindow(managerGlobalLeader_, this, &CRessourcesManager::ressourcesDumpOut) ;
-    winRessources_->unlockWindow(managerGlobalLeader_,0) ;    
+    winRessources_->updateToLockedWindow(managerGlobalLeader_, this, &CRessourcesManager::ressourcesDumpOut) ;
+    winRessources_->unlockWindowExclusive(managerGlobalLeader_) ;    
   }
   
   void CRessourcesManager::registerRessourcesSize(int size)
   {
-    winRessources_->lockWindow(managerGlobalLeader_,0) ;
-    winRessources_->updateFromWindow(managerGlobalLeader_, this, &CRessourcesManager::ressourcesDumpIn) ;
+    winRessources_->lockWindowExclusive(managerGlobalLeader_) ;
+    winRessources_->updateFromLockedWindow(managerGlobalLeader_, this, &CRessourcesManager::ressourcesDumpIn) ;
     ressourcesSize_ = size ;
     freeRessourcesSize_ = size ;
-    winRessources_->updateToWindow(managerGlobalLeader_, this, &CRessourcesManager::ressourcesDumpOut) ;
-    winRessources_->unlockWindow(managerGlobalLeader_,0) ;    
+    winRessources_->updateToLockedWindow(managerGlobalLeader_, this, &CRessourcesManager::ressourcesDumpOut) ;
+    winRessources_->unlockWindowExclusive(managerGlobalLeader_) ;    
   }
 
@@ -216,26 +212,24 @@
   void CRessourcesManager::registerPoolClient(const string& poolId, int size, int leader)
   {
-    winRessources_->lockWindow(managerGlobalLeader_,0) ;
-    winRessources_->updateFromWindow(managerGlobalLeader_, this, &CRessourcesManager::ressourcesDumpIn) ;
+    winRessources_->lockWindowExclusive(managerGlobalLeader_) ;
+    winRessources_->updateFromLockedWindow(managerGlobalLeader_, this, &CRessourcesManager::ressourcesDumpIn) ;
     pools_[poolId] = make_tuple(size, size, leader) ;
-    winRessources_->updateToWindow(managerGlobalLeader_, this, &CRessourcesManager::ressourcesDumpOut) ;
-    winRessources_->unlockWindow(managerGlobalLeader_,0) ;    
+    winRessources_->updateToLockedWindow(managerGlobalLeader_, this, &CRessourcesManager::ressourcesDumpOut) ;
+    winRessources_->unlockWindowExclusive(managerGlobalLeader_) ;    
   }
 
   void CRessourcesManager::registerPoolServer(const string& poolId, int size, int leader)
   {
-    winRessources_->lockWindow(managerGlobalLeader_,0) ;
-    winRessources_->updateFromWindow(managerGlobalLeader_, this, &CRessourcesManager::ressourcesDumpIn) ;
+    winRessources_->lockWindowExclusive(managerGlobalLeader_) ;
+    winRessources_->updateFromLockedWindow(managerGlobalLeader_, this, &CRessourcesManager::ressourcesDumpIn) ;
     pools_[poolId] = make_tuple(size, size, leader) ;
     freeRessourcesSize_-=size ;
-    winRessources_->updateToWindow(managerGlobalLeader_, this, &CRessourcesManager::ressourcesDumpOut) ;
-    winRessources_->unlockWindow(managerGlobalLeader_,0) ;    
+    winRessources_->updateToLockedWindow(managerGlobalLeader_, this, &CRessourcesManager::ressourcesDumpOut) ;
+    winRessources_->unlockWindowExclusive(managerGlobalLeader_) ;    
   }
 
   bool CRessourcesManager::getPoolInfo(const string& poolId, int& size, int& freeSize, int& leader)
   {
-    winRessources_->lockWindow(managerGlobalLeader_,0) ;
-    winRessources_->updateFromWindow(managerGlobalLeader_, this, &CRessourcesManager::ressourcesDumpIn) ;
-    winRessources_->unlockWindow(managerGlobalLeader_,0) ;
+    winRessources_->updateFromSharedWindow(managerGlobalLeader_, this, &CRessourcesManager::ressourcesDumpIn) ;
 
     auto it=pools_.find(poolId) ;
@@ -254,6 +248,6 @@
     bool ret ;
 
-    winRessources_->lockWindow(managerGlobalLeader_,0) ;
-    winRessources_->updateFromWindow(managerGlobalLeader_, this, &CRessourcesManager::ressourcesDumpIn) ;
+    winRessources_->lockWindowExclusive(managerGlobalLeader_) ;
+    winRessources_->updateFromLockedWindow(managerGlobalLeader_, this, &CRessourcesManager::ressourcesDumpIn) ;
    
 
@@ -266,6 +260,6 @@
       ret=true ;
     }
-    winRessources_->updateToWindow(managerGlobalLeader_, this, &CRessourcesManager::ressourcesDumpOut) ;
-    winRessources_->unlockWindow(managerGlobalLeader_,0) ; 
+    winRessources_->updateToLockedWindow(managerGlobalLeader_, this, &CRessourcesManager::ressourcesDumpOut) ;
+    winRessources_->unlockWindowExclusive(managerGlobalLeader_) ; 
 
     return ret ;   
@@ -274,8 +268,6 @@
   int CRessourcesManager::getRessourcesSize(void)
   {
-    winRessources_->lockWindow(managerGlobalLeader_,0) ;
-    winRessources_->updateFromWindow(managerGlobalLeader_, this, &CRessourcesManager::ressourcesDumpIn) ;
-    winRessources_->unlockWindow(managerGlobalLeader_,0) ;
-
+    winRessources_->updateFromSharedWindow(managerGlobalLeader_, this, &CRessourcesManager::ressourcesDumpIn) ;
+    
     return ressourcesSize_ ;
   }
@@ -283,7 +275,5 @@
   int CRessourcesManager::getFreeRessourcesSize(void)
   {
-    winRessources_->lockWindow(managerGlobalLeader_,0) ;
-    winRessources_->updateFromWindow(managerGlobalLeader_, this, &CRessourcesManager::ressourcesDumpIn) ;
-    winRessources_->unlockWindow(managerGlobalLeader_,0) ;
+    winRessources_->updateFromSharedWindow(managerGlobalLeader_, this, &CRessourcesManager::ressourcesDumpIn) ;
 
     return freeRessourcesSize_ ;
Index: XIOS3/trunk/src/manager/server_context.cpp
===================================================================
--- XIOS3/trunk/src/manager/server_context.cpp	(revision 2514)
+++ XIOS3/trunk/src/manager/server_context.cpp	(revision 2517)
@@ -160,7 +160,5 @@
   void CServerContext::sendNotification(int rank)
   {
-    winNotify_->lockWindowExclusive(rank) ;
-    winNotify_->pushToLockedWindow(rank, this, &CServerContext::notificationsDumpOut) ;
-    winNotify_->unlockWindow(rank) ;
+    winNotify_->pushToExclusiveWindow(rank, this, &CServerContext::notificationsDumpOut) ;
   }
 
@@ -201,8 +199,6 @@
         int commRank ;
         MPI_Comm_rank(contextComm_, &commRank) ;
-        winNotify_->lockWindowExclusive(commRank) ;
-        winNotify_->popFromLockedWindow(commRank, this, &CServerContext::notificationsDumpIn) ;
-        winNotify_->unlockWindow(commRank) ;
-      
+        winNotify_->popFromExclusiveWindow(commRank, this, &CServerContext::notificationsDumpIn) ;
+       
         if (notifyInType_!= NOTIFY_NOTHING)
         {
Index: XIOS3/trunk/src/manager/servers_ressource.cpp
===================================================================
--- XIOS3/trunk/src/manager/servers_ressource.cpp	(revision 2514)
+++ XIOS3/trunk/src/manager/servers_ressource.cpp	(revision 2517)
@@ -81,7 +81,5 @@
   void CServersRessource::sendNotification(int rank)
   {
-    winNotify_->lockWindow(rank,0) ;
-    winNotify_->pushToWindow(rank, this, &CServersRessource::notificationsDumpOut) ;
-    winNotify_->unlockWindow(rank,0) ;
+    winNotify_->pushToExclusiveWindow(rank, this, &CServersRessource::notificationsDumpOut) ;
   }
 
@@ -146,7 +144,5 @@
     int commRank ;
     MPI_Comm_rank(serverComm_, &commRank) ;
-    winNotify_->lockWindow(commRank,0) ;
-    winNotify_->popFromWindow(commRank, this, &CServersRessource::notificationsDumpIn) ;
-    winNotify_->unlockWindow(commRank,0) ;
+    winNotify_->popFromExclusiveWindow(commRank, this, &CServersRessource::notificationsDumpIn) ;
     if (notifyInType_==NOTIFY_CREATE_POOL) createPool() ;
     else if (notifyInType_==NOTIFY_FINALIZE) finalizeSignal() ;
Index: XIOS3/trunk/src/manager/services.cpp
===================================================================
--- XIOS3/trunk/src/manager/services.cpp	(revision 2514)
+++ XIOS3/trunk/src/manager/services.cpp	(revision 2517)
@@ -27,7 +27,5 @@
     
     winNotify_ = new CWindowManager(serviceComm_, maxBufferSize_) ;
-    winNotify_->lockWindow(localRank,0) ;
-    winNotify_->updateToWindow(localRank, this, &CService::createContextDumpOut) ;
-    winNotify_->unlockWindow(localRank,0) ;
+    winNotify_->updateToExclusiveWindow(localRank, this, &CService::createContextDumpOut) ;
     MPI_Barrier(serviceComm_) ;
     if (localRank==localLeader_) 
@@ -74,9 +72,9 @@
   void CService::createContextNotify(int rank, const std::string& poolId, const std::string& serviceId, const int& partitionId, const std::string& contextId)
   {
-    winNotify_->lockWindow(rank,0) ;
-    winNotify_->updateFromWindow(rank, this, &CService::createContextDumpIn) ;
+    winNotify_->lockWindowExclusive(rank) ;
+    winNotify_->updateFromLockedWindow(rank, this, &CService::createContextDumpIn) ;
     notifications_.push_back(std::make_tuple(poolId, serviceId, partitionId, contextId)) ;
-    winNotify_->updateToWindow(rank, this, &CService::createContextDumpOut) ;  
-    winNotify_->unlockWindow(rank,0) ;   
+    winNotify_->updateToLockedWindow(rank, this, &CService::createContextDumpOut) ;  
+    winNotify_->unlockWindowExclusive(rank) ;   
   }
 
@@ -143,7 +141,5 @@
   void CService::sendNotification(int rank)
   {
-    winNotify_->lockWindowExclusive(rank) ;
-    winNotify_->pushToLockedWindow(rank, this, &CService::notificationsDumpOut) ;
-    winNotify_->unlockWindow(rank) ;
+    winNotify_->pushToExclusiveWindow(rank, this, &CService::notificationsDumpOut) ;
   }
 
@@ -187,8 +183,6 @@
         int commRank ;
         MPI_Comm_rank(serviceComm_, &commRank) ;
-        winNotify_->lockWindowExclusive(commRank) ;
-        winNotify_->popFromLockedWindow(commRank, this, &CService::notificationsDumpIn) ;
-        winNotify_->unlockWindow(commRank) ;
-      
+        winNotify_->popFromExclusiveWindow(commRank, this, &CService::notificationsDumpIn) ;
+        
         if (notifyInType_!= NOTIFY_NOTHING)
         {
@@ -227,6 +221,6 @@
     int commRank ;
     MPI_Comm_rank(serviceComm_, &commRank) ;
-    winNotify_->lockWindow(commRank,0) ;
-    winNotify_->updateFromWindow(commRank, this, &CService::createContextDumpIn) ;
+    winNotify_->lockWindowExclusive(commRank) ;
+    winNotify_->updateFromLockedWindow(commRank, this, &CService::createContextDumpIn) ;
     
     if (!notifications_.empty())
@@ -235,7 +229,7 @@
       createNewContext(get<0>(info), get<1>(info), get<2>(info), get<3>(info)) ;
       notifications_.pop_front() ;
-      winNotify_->updateToWindow(commRank, this, &CService::createContextDumpOut) ;     
-    }
-    winNotify_->unlockWindow(commRank,0) ;
+      winNotify_->updateToLockedWindow(commRank, this, &CService::createContextDumpOut) ;     
+    }
+    winNotify_->unlockWindowExclusive(commRank) ;
   }
 
Index: XIOS3/trunk/src/manager/services_manager.cpp
===================================================================
--- XIOS3/trunk/src/manager/services_manager.cpp	(revision 2514)
+++ XIOS3/trunk/src/manager/services_manager.cpp	(revision 2517)
@@ -31,13 +31,9 @@
     MPI_Comm_rank(xiosComm_, &commRank) ;
     winNotify_ = new CWindowManager(xiosComm_, maxBufferSize_) ;
-    winNotify_->lockWindow(commRank,0) ;
-    winNotify_->updateToWindow(commRank, this, &CServicesManager::notificationsDumpOut) ;
-    winNotify_->unlockWindow(commRank,0) ;
+    winNotify_->updateToExclusiveWindow(commRank, this, &CServicesManager::notificationsDumpOut) ;
 
     winServices_ = new CWindowManager(xiosComm_, maxBufferSize_) ;
-    winServices_->lockWindow(commRank,0) ;
-    winServices_->updateToWindow(commRank, this, &CServicesManager::servicesDumpOut) ;
-    winServices_->unlockWindow(commRank,0) ;
-
+    winServices_->updateToExclusiveWindow(commRank, this, &CServicesManager::servicesDumpOut) ;
+   
     MPI_Barrier(xiosComm_)  ;    
   }
@@ -121,7 +117,5 @@
   void CServicesManager::sendNotification(int rank)
   {
-    winNotify_->lockWindowExclusive(rank) ;
-    winNotify_->pushToLockedWindow(rank, this, &CServicesManager::notificationsDumpOut) ;
-    winNotify_->unlockWindow(rank) ;
+    winNotify_->pushToExclusiveWindow(rank, this, &CServicesManager::notificationsDumpOut) ;
   }
 
@@ -147,7 +141,5 @@
     int commRank ;
     MPI_Comm_rank(xiosComm_, &commRank) ;
-    winNotify_->lockWindowExclusive(commRank) ;
-    winNotify_->popFromLockedWindow(commRank, this, &CServicesManager::notificationsDumpIn) ;
-    winNotify_->unlockWindow(commRank) ;
+    winNotify_->popFromExclusiveWindow(commRank, this, &CServicesManager::notificationsDumpIn) ;
     if (notifyType_==NOTIFY_CREATE_SERVICE) createService() ;
     else if (notifyType_==NOTIFY_CREATE_SERVICE_ONTO) createServiceOnto() ;
@@ -253,5 +245,5 @@
     services_[std::tuple<std::string, std::string,int>(poolId,serviceId,partitionId)]=std::make_tuple(type,size,nbPartitions,leader) ;
     winServices_->updateToLockedWindow(managerGlobalLeader_, this, &CServicesManager::servicesDumpOut) ;
-    winServices_->unlockWindow(managerGlobalLeader_) ;
+    winServices_->unlockWindowExclusive(managerGlobalLeader_) ;
 
   }
@@ -260,7 +252,5 @@
                                         int& size, int& nbPartitions, int& leader, bool wait)
   {
-    winServices_->lockWindowShared(managerGlobalLeader_) ;
-    winServices_->updateFromLockedWindow(managerGlobalLeader_, this, &CServicesManager::servicesDumpIn) ;
-    winServices_->unlockWindow(managerGlobalLeader_) ;
+    winServices_->updateFromSharedWindow(managerGlobalLeader_, this, &CServicesManager::servicesDumpIn) ;
     
     if (wait) waitServiceRegistration(poolId, serviceId, partitionId) ;
@@ -303,7 +293,5 @@
   bool CServicesManager::hasService(const std::string& poolId, const std::string& serviceId, const int& partitionId)
   {
-    winServices_->lockWindowShared(managerGlobalLeader_) ;
-    winServices_->updateFromLockedWindow(managerGlobalLeader_, this, &CServicesManager::servicesDumpIn) ;
-    winServices_->unlockWindow(managerGlobalLeader_) ;
+    winServices_->updateFromSharedWindow(managerGlobalLeader_, this, &CServicesManager::servicesDumpIn) ;
     auto it=services_.find(std::tuple<std::string, std::string, int>(poolId, serviceId, partitionId)) ;
     if ( it == services_.end()) return false ;
Index: XIOS3/trunk/src/manager/window_base.cpp
===================================================================
--- XIOS3/trunk/src/manager/window_base.cpp	(revision 2517)
+++ XIOS3/trunk/src/manager/window_base.cpp	(revision 2517)
@@ -0,0 +1,7 @@
+#include "window_base.hpp"
+
+namespace xios
+{
+  
+  
+}
Index: XIOS3/trunk/src/manager/window_base.hpp
===================================================================
--- XIOS3/trunk/src/manager/window_base.hpp	(revision 2517)
+++ XIOS3/trunk/src/manager/window_base.hpp	(revision 2517)
@@ -0,0 +1,157 @@
+#ifndef __WINDOW_BASE_HPP__
+#define __WINDOW_BASE_HPP__
+
+#include <map>
+#include "exception.hpp"
+#include "mpi.hpp"
+
+namespace xios
+{
+
+
+  class CWindowBase
+  {
+    private:
+      void * winBuffer_ ;   
+      const MPI_Aint OFFSET_LOCK=0 ;
+      const int SIZE_LOCK=sizeof(long) ;
+      const MPI_Aint OFFSET_BUFFER =  SIZE_LOCK ;
+      MPI_Aint bufferSize_ ;
+      MPI_Aint windowSize_ ;
+      const double maxLatency_ = 1e-3 ; // 1ms latency maximum
+      MPI_Win window_ ;
+
+    public :
+
+    CWindowBase(MPI_Comm winComm, size_t bufferSize)
+    {
+      bufferSize_ = bufferSize ;
+      windowSize_ = bufferSize_ + OFFSET_BUFFER ;
+      MPI_Win_allocate(windowSize_, 1, MPI_INFO_NULL, winComm, &winBuffer_, &window_) ;
+      MPI_Aint& lock = *((MPI_Aint*)((char*)winBuffer_+OFFSET_LOCK)) ;
+      lock=0 ;
+      MPI_Win_lock_all(0, window_) ;
+      MPI_Barrier(winComm) ;
+    }
+
+    bool tryLockExclusive(int rank)
+    {
+      long lock = 1;
+      long unlock = 0;
+      long state;
+
+      int flag ;
+      MPI_Compare_and_swap(&lock, &unlock, &state, MPI_LONG, rank, OFFSET_LOCK, window_) ;
+      MPI_Win_flush(rank, window_);
+
+      bool locked = (state == unlock) ;
+      return locked ;
+    }
+
+    bool tryLockShared(int rank, MPI_Op op)
+    {
+      long one = 0x100000000;
+      long res;
+
+      MPI_Fetch_and_op(&one, &res, MPI_LONG, rank, OFFSET_LOCK, op, window_);
+      MPI_Win_flush(rank, window_);
+      
+      bool locked =  ! (res & 1) ;
+      return locked ;
+    }
+
+    void unlockExclusive(int rank)
+    {
+      int lock = 1;
+      int unlock = 0;
+      int state;
+
+      MPI_Win_flush(rank, window_);
+      MPI_Compare_and_swap(&unlock, &lock, &state, MPI_INT, rank, OFFSET_LOCK, window_) ;
+      MPI_Win_flush(rank, window_);
+      if (lock != state) ERROR("CWindowBase::unlockWindowExclusive",<<"unlockWindow failed: bad state"<<endl) ; 
+    }
+
+    void unlockShared(int rank)
+    {
+      int minusone = -1;
+      int res;
+      MPI_Fetch_and_op(&minusone, &res, MPI_INT, rank, OFFSET_LOCK+4, MPI_SUM, window_);
+      MPI_Win_flush(rank, window_);
+    }
+
+    void lockExclusive(int rank)
+    {
+      double time =  MPI_Wtime() ;
+      bool locked = tryLockExclusive(rank);
+      double lastTime = MPI_Wtime() ;
+      double delta = lastTime-time ;
+      
+      while (!locked)
+      {
+        time = MPI_Wtime() ;
+        if (delta > maxLatency_) delta = maxLatency_ ;
+        if (time >= lastTime+delta)
+        { 
+          locked = tryLockExclusive(rank);
+          delta=delta*2.;
+          lastTime = time ;      
+        }
+      }  
+    }
+
+    void lockShared(int rank)
+    {
+      double time =  MPI_Wtime() ;
+      bool locked = tryLockShared(rank, MPI_SUM);
+      double lastTime = MPI_Wtime() ;
+      double delta = lastTime-time ;
+      
+      while (!locked)
+      {
+        time = MPI_Wtime() ;
+        if (delta > maxLatency_) delta = maxLatency_ ;
+        if (time >= lastTime+delta)
+        { 
+          locked = tryLockShared(rank, MPI_NO_OP);
+          delta=delta*2.;
+          lastTime = time ;      
+        }
+      }  
+    }
+
+    int flush(int rank)
+    {
+      return MPI_Win_flush(rank, window_) ;
+    }
+
+    int put(const void *origin_addr, int origin_count, MPI_Datatype origin_datatype, int target_rank, MPI_Aint target_disp,
+            int target_count, MPI_Datatype target_datatype)
+    {
+      return MPI_Put(origin_addr, origin_count, origin_datatype, target_rank,  target_disp + OFFSET_BUFFER, target_count, target_datatype, window_) ;
+    }
+
+    int get(void *origin_addr, int origin_count, MPI_Datatype origin_datatype, int target_rank, MPI_Aint target_disp,
+            int target_count, MPI_Datatype target_datatype)
+    {
+      return MPI_Get(origin_addr, origin_count, origin_datatype, target_rank, target_disp + OFFSET_BUFFER, target_count, target_datatype, window_) ;
+    }
+
+    int compareAndSwap(const void *origin_addr, const void *compare_addr, void *result_addr, MPI_Datatype datatype,
+                       int target_rank, MPI_Aint target_disp)
+    {
+      return MPI_Compare_and_swap(origin_addr, compare_addr, result_addr, datatype, target_rank, target_disp + OFFSET_BUFFER, window_) ;
+    }
+
+    ~CWindowBase()
+    {
+      MPI_Win_unlock_all(window_);
+      MPI_Win_free(&window_) ;
+    }
+
+  } ;
+}
+
+
+
+#endif
Index: XIOS3/trunk/src/manager/window_manager.cpp
===================================================================
--- XIOS3/trunk/src/manager/window_manager.cpp	(revision 2514)
+++ XIOS3/trunk/src/manager/window_manager.cpp	(revision 2517)
@@ -7,5 +7,10 @@
 {
   
-  
+    const MPI_Aint CWindowManager::OFFSET_LOCK ;
+    const int CWindowManager::SIZE_LOCK ;
+    const MPI_Aint CWindowManager::OFFSET_BUFFER_SIZE ;
+    const int CWindowManager::SIZE_BUFFER_SIZE ;
+    const MPI_Aint CWindowManager::OFFSET_BUFFER;
+    const int CWindowManager::WINDOWS_LOCKED ;
 }
 
Index: XIOS3/trunk/src/manager/window_manager.hpp
===================================================================
--- XIOS3/trunk/src/manager/window_manager.hpp	(revision 2514)
+++ XIOS3/trunk/src/manager/window_manager.hpp	(revision 2517)
@@ -7,4 +7,5 @@
 #include "buffer_out.hpp"
 #include "message.hpp"
+#include "window_base.hpp"
 
 namespace xios
@@ -12,14 +13,14 @@
 
 
-  class CWindowManager
+  class CWindowManager : public CWindowBase 
   {
 
     private :
-    const MPI_Aint OFFSET_LOCK=0 ;
-    const int SIZE_LOCK=sizeof(int) ;
-    const MPI_Aint OFFSET_BUFFER_SIZE=OFFSET_LOCK+SIZE_LOCK ;
-    const int SIZE_BUFFER_SIZE=sizeof(size_t) ;
-    const MPI_Aint OFFSET_BUFFER=OFFSET_BUFFER_SIZE+SIZE_BUFFER_SIZE ;
-    const int WINDOWS_LOCKED=-1 ;
+    static const MPI_Aint OFFSET_LOCK=0 ;
+    static const int SIZE_LOCK=sizeof(int) ;
+    static const MPI_Aint OFFSET_BUFFER_SIZE=OFFSET_LOCK+SIZE_LOCK ;
+    static const int SIZE_BUFFER_SIZE=sizeof(size_t) ;
+    static const MPI_Aint OFFSET_BUFFER=OFFSET_BUFFER_SIZE+SIZE_BUFFER_SIZE ;
+    static const int WINDOWS_LOCKED=-1 ;
 
     MPI_Win window_ ;
@@ -30,16 +31,14 @@
     public :
 
-    CWindowManager(MPI_Comm winComm, size_t bufferSize)
-    {
-      const MPI_Aint windowSize=bufferSize+OFFSET_BUFFER ;
-      MPI_Win_allocate(windowSize, 1, MPI_INFO_NULL, winComm, &winBuffer_, &window_) ;
+    CWindowManager(MPI_Comm winComm, size_t bufferSize) : CWindowBase(winComm, bufferSize + OFFSET_BUFFER_SIZE)
+    {
       int lock=0 ;
       size_t size=0 ;
       int commRank ;
       MPI_Comm_rank(winComm, &commRank) ;
-      MPI_Win_lock(MPI_LOCK_EXCLUSIVE, commRank, 0, window_) ;
-      MPI_Put(&lock, SIZE_LOCK, MPI_CHAR, commRank, OFFSET_LOCK, SIZE_LOCK, MPI_CHAR, window_) ;
-      MPI_Put(&size, SIZE_BUFFER_SIZE, MPI_CHAR, commRank, OFFSET_BUFFER_SIZE, SIZE_BUFFER_SIZE, MPI_CHAR, window_) ;
-      MPI_Win_unlock(commRank, window_) ;
+      lockExclusive(commRank) ;
+      put(&lock, SIZE_LOCK, MPI_CHAR, commRank, OFFSET_LOCK, SIZE_LOCK, MPI_CHAR) ;
+      put(&size, SIZE_BUFFER_SIZE, MPI_CHAR, commRank, OFFSET_BUFFER_SIZE, SIZE_BUFFER_SIZE, MPI_CHAR) ;
+      unlockExclusive(commRank) ;
       MPI_Barrier(winComm) ;
     }
@@ -63,7 +62,6 @@
         int flag ;
         MPI_Iprobe(MPI_ANY_SOURCE, MPI_ANY_TAG, MPI_COMM_WORLD, &flag, MPI_STATUS_IGNORE);
-        MPI_Win_lock(MPI_LOCK_EXCLUSIVE, rank, 0, window_) ;
-        MPI_Compare_and_swap(&WINDOWS_LOCKED, &state, &lock, MPI_INT, rank, OFFSET_LOCK, window_) ;
-        MPI_Win_unlock(rank, window_) ;
+        compareAndSwap(&WINDOWS_LOCKED, &state, &lock, MPI_INT, rank, OFFSET_LOCK) ;
+        flush(rank) ;
         lastTime=MPI_Wtime() ;
       } while (lock!=state) ;
@@ -90,7 +88,7 @@
         int flag ;
         MPI_Iprobe(MPI_ANY_SOURCE, MPI_ANY_TAG, MPI_COMM_WORLD, &flag, MPI_STATUS_IGNORE);
-        MPI_Win_lock(MPI_LOCK_EXCLUSIVE, rank, 0, window_) ;
-        MPI_Compare_and_swap(&WINDOWS_LOCKED, &state, &lock, MPI_INT, rank, OFFSET_LOCK, window_) ;
-        MPI_Win_unlock(rank, window_) ;
+        lockExclusive(rank) ;
+        compareAndSwap(&WINDOWS_LOCKED, &state, &lock, MPI_INT, rank, OFFSET_LOCK) ;
+        unlockExclusive(rank) ;
         lastTime=MPI_Wtime() ;
       } while (lock!=state) ;
@@ -99,20 +97,35 @@
     void lockWindowExclusive(int rank)
     {
-      MPI_Win_lock(MPI_LOCK_EXCLUSIVE, rank, 0, window_) ;
+      lockExclusive(rank) ;
     }
 
     void lockWindowShared(int rank)
     {
-      MPI_Win_lock(MPI_LOCK_SHARED, rank, 0, window_) ;
-    }
-
+      lockShared(rank) ;
+    }
+
+    void unlockWindowExclusive(int rank)
+    {
+      unlockExclusive(rank) ;
+    }
+
+    void unlockWindowShared(int rank)
+    {
+      unlockShared(rank) ;
+    }
+
+    void lockWindow(int rank)
+    {
+      lockWindowExclusive(rank) ;
+    }
+    
     void unlockWindow(int rank)
     {
-      MPI_Win_unlock(rank, window_) ;
+      unlockWindowExclusive(rank) ;
     }
 
     void flushWindow(int rank)
     {
-      MPI_Win_flush(rank, window_) ;
+      flush(rank) ;
     }
 
@@ -120,56 +133,40 @@
     {
       int lock ;
-      MPI_Win_lock(MPI_LOCK_EXCLUSIVE, rank, 0, window_) ;
-      MPI_Compare_and_swap(&state, &WINDOWS_LOCKED, &lock, MPI_INT, rank, OFFSET_LOCK, window_) ;
-      MPI_Win_unlock(rank, window_) ;
+      compareAndSwap(&state, &WINDOWS_LOCKED, &lock, MPI_INT, rank, OFFSET_LOCK) ;
+      flush(rank) ;
     }
     
     template< class T >
     void updateToWindow(int rank, T* object, void (T::*dumpOut)(CBufferOut&) )
+    {
+      updateToExclusiveWindow(rank, object, dumpOut) ;
+    }
+
+    template< class T >
+    void updateToExclusiveWindow(int rank, T* object, void (T::*dumpOut)(CBufferOut&) )
+    {
+      lockExclusive(rank) ;
+      updateToLockedWindow(rank, object, dumpOut) ;
+      unlockExclusive(rank) ;
+     }
+
+    template< class T >
+    void updateTosharedWindow(int rank, T* object, void (T::*dumpOut)(CBufferOut&) )
+    {
+      lockShared(rank) ;
+      updateToLockedWindow(rank, object, dumpOut) ;
+      unlockShared(rank) ;
+    }
+
+    template< class T >
+    void updateToLockedWindow(int rank, T* object, void (T::*dumpOut)(CBufferOut&) )
     {
       CBufferOut buffer ;
       (object->*dumpOut)(buffer) ;
       size_t size=buffer.count() ;
-      MPI_Win_lock(MPI_LOCK_EXCLUSIVE, rank, 0, window_) ;
-      MPI_Put(&size, SIZE_BUFFER_SIZE, MPI_CHAR, rank, OFFSET_BUFFER_SIZE, SIZE_BUFFER_SIZE, MPI_CHAR, window_) ;
-      MPI_Put(buffer.start(), size, MPI_CHAR, rank,OFFSET_BUFFER, size, MPI_CHAR, window_) ;
-      MPI_Win_unlock(rank, window_) ;
-    }
-
-    template< class T >
-    void updateToExclusiveWindow(int rank, T* object, void (T::*dumpOut)(CBufferOut&) )
-    {
-      CBufferOut buffer ;
-      (object->*dumpOut)(buffer) ;
-      size_t size=buffer.count() ;
-      MPI_Win_lock(MPI_LOCK_EXCLUSIVE, rank, 0, window_) ;
-      MPI_Put(&size, SIZE_BUFFER_SIZE, MPI_CHAR, rank, OFFSET_BUFFER_SIZE, SIZE_BUFFER_SIZE, MPI_CHAR, window_) ;
-      MPI_Put(buffer.start(), size, MPI_CHAR, rank,OFFSET_BUFFER, size, MPI_CHAR, window_) ;
-      MPI_Win_unlock(rank, window_) ;
-    }
-
-    template< class T >
-    void updateTosharedWindow(int rank, T* object, void (T::*dumpOut)(CBufferOut&) )
-    {
-      CBufferOut buffer ;
-      (object->*dumpOut)(buffer) ;
-      size_t size=buffer.count() ;
-      MPI_Win_lock(MPI_LOCK_SHARED, rank, 0, window_) ;
-      MPI_Put(&size, SIZE_BUFFER_SIZE, MPI_CHAR, rank, OFFSET_BUFFER_SIZE, SIZE_BUFFER_SIZE, MPI_CHAR, window_) ;
-      MPI_Put(buffer.start(), size, MPI_CHAR, rank,OFFSET_BUFFER, size, MPI_CHAR, window_) ;
-      MPI_Win_unlock(rank, window_) ;
-    }
-
-    template< class T >
-    void updateToLockedWindow(int rank, T* object, void (T::*dumpOut)(CBufferOut&) )
-    {
-      CBufferOut buffer ;
-      (object->*dumpOut)(buffer) ;
-      size_t size=buffer.count() ;
-//      MPI_Win_lock(MPI_LOCK_EXCLUSIVE, rank, 0, window_) ;
-      MPI_Put(&size, SIZE_BUFFER_SIZE, MPI_CHAR, rank, OFFSET_BUFFER_SIZE, SIZE_BUFFER_SIZE, MPI_CHAR, window_) ;
-      MPI_Put(buffer.start(), size, MPI_CHAR, rank,OFFSET_BUFFER, size, MPI_CHAR, window_) ;
-      MPI_Win_flush(rank, window_) ;
-//      MPI_Win_unlock(rank, window_) ;
+
+      put(&size, SIZE_BUFFER_SIZE, MPI_CHAR, rank, OFFSET_BUFFER_SIZE, SIZE_BUFFER_SIZE, MPI_CHAR) ;
+      put(buffer.start(), size, MPI_CHAR, rank,OFFSET_BUFFER, size, MPI_CHAR) ;
+      flush(rank) ;
     }
 
@@ -177,53 +174,39 @@
     void updateFromWindow(int rank, T* object, void (T::*dumpIn)(CBufferIn&) ) 
     {
-      size_t size ;
-      MPI_Win_lock(MPI_LOCK_EXCLUSIVE, rank, 0, window_) ;
-      MPI_Get(&size, SIZE_BUFFER_SIZE, MPI_CHAR, rank, OFFSET_BUFFER_SIZE, SIZE_BUFFER_SIZE, MPI_CHAR, window_) ;
-      MPI_Win_flush(rank,window_) ;
+      updateFromExclusiveWindow(rank,object, dumpIn) ;
+    }
+
+    template< typename T >
+    void updateFromExclusiveWindow(int rank, T* object, void (T::*dumpIn)(CBufferIn&) ) 
+    {
+      size_t size ;
+      lockExclusive(rank) ;
+      updateFromLockedWindow(rank,object, dumpIn) ;
+      unlockExclusive(rank) ;
+    }
+
+    template< typename T >
+    void updateFromSharedWindow(int rank, T* object, void (T::*dumpIn)(CBufferIn&) ) 
+    {
+      size_t size ;
+      lockShared(rank) ;
+      updateFromLockedWindow(rank,object, dumpIn) ;
+      unlockShared(rank) ;
+    }
+
+    template< typename T >
+    void updateFromLockedWindow(int rank, T* object, void (T::*dumpIn)(CBufferIn&) ) 
+    {
+      size_t size ;
+
+      get(&size, SIZE_BUFFER_SIZE, MPI_CHAR, rank, OFFSET_BUFFER_SIZE, SIZE_BUFFER_SIZE, MPI_CHAR) ;
+      flush(rank) ;
       CBufferIn buffer(size) ;
-      MPI_Get(buffer.start(), size, MPI_CHAR, rank,OFFSET_BUFFER, size, MPI_CHAR, window_) ;
-      MPI_Win_unlock(rank, window_) ;
+      get(buffer.start(), size, MPI_CHAR, rank,OFFSET_BUFFER, size, MPI_CHAR) ;
+      flush(rank) ;
+
       (object->*dumpIn)(buffer) ;
     }
 
-    template< typename T >
-    void updateFromExclusiveWindow(int rank, T* object, void (T::*dumpIn)(CBufferIn&) ) 
-    {
-      size_t size ;
-      MPI_Win_lock(MPI_LOCK_EXCLUSIVE, rank, 0, window_) ;
-      MPI_Get(&size, SIZE_BUFFER_SIZE, MPI_CHAR, rank, OFFSET_BUFFER_SIZE, SIZE_BUFFER_SIZE, MPI_CHAR, window_) ;
-      MPI_Win_flush(rank,window_) ;
-      CBufferIn buffer(size) ;
-      MPI_Get(buffer.start(), size, MPI_CHAR, rank,OFFSET_BUFFER, size, MPI_CHAR, window_) ;
-      MPI_Win_unlock(rank, window_) ;
-      (object->*dumpIn)(buffer) ;
-    }
-
-    template< typename T >
-    void updateFromSharedWindow(int rank, T* object, void (T::*dumpIn)(CBufferIn&) ) 
-    {
-      size_t size ;
-      MPI_Win_lock(MPI_LOCK_SHARED, rank, 0, window_) ;
-      MPI_Get(&size, SIZE_BUFFER_SIZE, MPI_CHAR, rank, OFFSET_BUFFER_SIZE, SIZE_BUFFER_SIZE, MPI_CHAR, window_) ;
-      MPI_Win_flush(rank,window_) ;
-      CBufferIn buffer(size) ;
-      MPI_Get(buffer.start(), size, MPI_CHAR, rank,OFFSET_BUFFER, size, MPI_CHAR, window_) ;
-      MPI_Win_unlock(rank, window_) ;
-      (object->*dumpIn)(buffer) ;
-    }
-
-    template< typename T >
-    void updateFromLockedWindow(int rank, T* object, void (T::*dumpIn)(CBufferIn&) ) 
-    {
-      size_t size ;
-//      MPI_Win_lock(MPI_LOCK_SHARED, rank, 0, window_) ;
-      MPI_Get(&size, SIZE_BUFFER_SIZE, MPI_CHAR, rank, OFFSET_BUFFER_SIZE, SIZE_BUFFER_SIZE, MPI_CHAR, window_) ;
-      MPI_Win_flush(rank,window_) ;
-      CBufferIn buffer(size) ;
-      MPI_Get(buffer.start(), size, MPI_CHAR, rank,OFFSET_BUFFER, size, MPI_CHAR, window_) ;
-//      MPI_Win_unlock(rank, window_) ;
-      MPI_Win_flush(rank, window_) ;
-      (object->*dumpIn)(buffer) ;
-    }
 
 
@@ -231,141 +214,82 @@
     void pushToWindow(int rank, T* object, void (T::*dumpOut)(CBufferOut&) )
     {
-      size_t size ;
-      MPI_Win_lock(MPI_LOCK_EXCLUSIVE, rank, 0, window_) ;
-      MPI_Get(&size, SIZE_BUFFER_SIZE, MPI_CHAR, rank, OFFSET_BUFFER_SIZE, SIZE_BUFFER_SIZE, MPI_CHAR, window_) ;
-      MPI_Win_flush(rank,window_) ;
+      pushToExclusiveWindow(rank, object, dumpOut) ;
+    }
+
+    template< class T >
+    void pushToExclusiveWindow(int rank, T* object, void (T::*dumpOut)(CBufferOut&) )
+    {
+      lockExclusive(rank) ;
+      pushToLockedWindow(rank, object, dumpOut) ;
+      unlockExclusive(rank) ;
+    }
+
+    template< class T >
+    void pushToSharedWindow(int rank, T* object, void (T::*dumpOut)(CBufferOut&) )
+    {
+      lockShared(rank) ;
+      pushToLockedWindow(rank, object, dumpOut) ;
+      unlockShared(rank) ;
+    }
+
+    template< class T >
+    void pushToLockedWindow(int rank, T* object, void (T::*dumpOut)(CBufferOut&) )
+    {
+      size_t size ;
+      get(&size, SIZE_BUFFER_SIZE, MPI_CHAR, rank, OFFSET_BUFFER_SIZE, SIZE_BUFFER_SIZE, MPI_CHAR) ;
+      flush(rank) ;
       CBufferOut buffer ;
       (object->*dumpOut)(buffer) ;
       size_t bufferSize=buffer.count() ;
       size_t newSize = size + bufferSize;
-      MPI_Put(&newSize, SIZE_BUFFER_SIZE, MPI_CHAR, rank, OFFSET_BUFFER_SIZE, SIZE_BUFFER_SIZE, MPI_CHAR, window_) ;
-      MPI_Put(buffer.start(), bufferSize, MPI_CHAR, rank, OFFSET_BUFFER+size, bufferSize, MPI_CHAR, window_) ;
-      MPI_Win_unlock(rank, window_) ;
-    }
-
-    template< class T >
-    void pushToExclusiveWindow(int rank, T* object, void (T::*dumpOut)(CBufferOut&) )
-    {
-      size_t size ;
-      MPI_Win_lock(MPI_LOCK_EXCLUSIVE, rank, 0, window_) ;
-      MPI_Get(&size, SIZE_BUFFER_SIZE, MPI_CHAR, rank, OFFSET_BUFFER_SIZE, SIZE_BUFFER_SIZE, MPI_CHAR, window_) ;
-      MPI_Win_flush(rank,window_) ;
-      CBufferOut buffer ;
-      (object->*dumpOut)(buffer) ;
-      size_t bufferSize=buffer.count() ;
-      size_t newSize = size + bufferSize;
-      MPI_Put(&newSize, SIZE_BUFFER_SIZE, MPI_CHAR, rank, OFFSET_BUFFER_SIZE, SIZE_BUFFER_SIZE, MPI_CHAR, window_) ;
-      MPI_Put(buffer.start(), bufferSize, MPI_CHAR, rank, OFFSET_BUFFER+size, bufferSize, MPI_CHAR, window_) ;
-      MPI_Win_unlock(rank, window_) ;
-    }
-
-    template< class T >
-    void pushToSharedWindow(int rank, T* object, void (T::*dumpOut)(CBufferOut&) )
-    {
-      size_t size ;
-      MPI_Win_lock(MPI_LOCK_SHARED, rank, 0, window_) ;
-      MPI_Get(&size, SIZE_BUFFER_SIZE, MPI_CHAR, rank, OFFSET_BUFFER_SIZE, SIZE_BUFFER_SIZE, MPI_CHAR, window_) ;
-      MPI_Win_flush(rank,window_) ;
-      CBufferOut buffer ;
-      (object->*dumpOut)(buffer) ;
-      size_t bufferSize=buffer.count() ;
-      size_t newSize = size + bufferSize;
-      MPI_Put(&newSize, SIZE_BUFFER_SIZE, MPI_CHAR, rank, OFFSET_BUFFER_SIZE, SIZE_BUFFER_SIZE, MPI_CHAR, window_) ;
-      MPI_Put(buffer.start(), bufferSize, MPI_CHAR, rank, OFFSET_BUFFER+size, bufferSize, MPI_CHAR, window_) ;
-      MPI_Win_unlock(rank, window_) ;
-    }
-
-    template< class T >
-    void pushToLockedWindow(int rank, T* object, void (T::*dumpOut)(CBufferOut&) )
-    {
-      size_t size ;
-      MPI_Get(&size, SIZE_BUFFER_SIZE, MPI_CHAR, rank, OFFSET_BUFFER_SIZE, SIZE_BUFFER_SIZE, MPI_CHAR, window_) ;
-      MPI_Win_flush(rank,window_) ;
-      CBufferOut buffer ;
-      (object->*dumpOut)(buffer) ;
-      size_t bufferSize=buffer.count() ;
-      size_t newSize = size + bufferSize;
-      MPI_Put(&newSize, SIZE_BUFFER_SIZE, MPI_CHAR, rank, OFFSET_BUFFER_SIZE, SIZE_BUFFER_SIZE, MPI_CHAR, window_) ;
-      MPI_Put(buffer.start(), bufferSize, MPI_CHAR, rank, OFFSET_BUFFER+size, bufferSize, MPI_CHAR, window_) ;
-      MPI_Win_flush(rank, window_) ;
-    }
+      put(&newSize, SIZE_BUFFER_SIZE, MPI_CHAR, rank, OFFSET_BUFFER_SIZE, SIZE_BUFFER_SIZE, MPI_CHAR) ;
+      put(buffer.start(), bufferSize, MPI_CHAR, rank, OFFSET_BUFFER+size, bufferSize, MPI_CHAR) ;
+      flush(rank) ;
+    }
+
+
 
     template< typename T >
     void popFromWindow(int rank, T* object, void (T::*dumpIn)(CBufferIn&) ) 
     {
-      size_t size ;
-      MPI_Win_lock(MPI_LOCK_EXCLUSIVE, rank, 0, window_) ;
-      MPI_Get(&size, SIZE_BUFFER_SIZE, MPI_CHAR, rank, OFFSET_BUFFER_SIZE, SIZE_BUFFER_SIZE, MPI_CHAR, window_) ;
-      MPI_Win_flush(rank,window_) ;
+      popFromExclusiveWindow(rank,object, dumpIn) ; 
+    }
+
+    template< typename T >
+    void popFromExclusiveWindow(int rank, T* object, void (T::*dumpIn)(CBufferIn&) ) 
+    {
+      lockExclusive(rank) ;
+      popFromLockedWindow(rank,object, dumpIn) ; 
+      unlockExclusive(rank) ;
+      
+    }
+
+    template< typename T >
+    void popFromSharedWindow(int rank, T* object, void (T::*dumpIn)(CBufferIn&) ) 
+    {
+      lockShared(rank) ;
+      popFromLockedWindow(rank,object, dumpIn) ; 
+      unlockShared(rank) ;
+    }
+
+    template< typename T >
+    void popFromLockedWindow(int rank, T* object, void (T::*dumpIn)(CBufferIn&) ) 
+    {
+      size_t size ;
+      get(&size, SIZE_BUFFER_SIZE, MPI_CHAR, rank, OFFSET_BUFFER_SIZE, SIZE_BUFFER_SIZE, MPI_CHAR) ;
+      flush(rank) ;
       CBufferIn buffer(size) ;
-      MPI_Get(buffer.start(), size, MPI_CHAR, rank,OFFSET_BUFFER, size, MPI_CHAR, window_) ;
-      MPI_Win_flush(rank,window_) ;
+      get(buffer.start(), size, MPI_CHAR, rank,OFFSET_BUFFER, size, MPI_CHAR) ;
+      flush(rank) ;
       (object->*dumpIn)(buffer) ;
       
       size=buffer.remain() ;
-      MPI_Put(&size, SIZE_BUFFER_SIZE, MPI_CHAR, rank, OFFSET_BUFFER_SIZE, SIZE_BUFFER_SIZE, MPI_CHAR, window_) ;
-      MPI_Put(buffer.ptr(),buffer.remain(), MPI_CHAR, rank, OFFSET_BUFFER, buffer.remain(), MPI_CHAR, window_) ;
-      MPI_Win_unlock(rank, window_) ;
-      
-    }
-
-    template< typename T >
-    void popFromExclusiveWindow(int rank, T* object, void (T::*dumpIn)(CBufferIn&) ) 
-    {
-      size_t size ;
-      MPI_Win_lock(MPI_LOCK_EXCLUSIVE, rank, 0, window_) ;
-      MPI_Get(&size, SIZE_BUFFER_SIZE, MPI_CHAR, rank, OFFSET_BUFFER_SIZE, SIZE_BUFFER_SIZE, MPI_CHAR, window_) ;
-      MPI_Win_flush(rank,window_) ;
-      CBufferIn buffer(size) ;
-      MPI_Get(buffer.start(), size, MPI_CHAR, rank,OFFSET_BUFFER, size, MPI_CHAR, window_) ;
-      MPI_Win_flush(rank,window_) ;
-      (object->*dumpIn)(buffer) ;
-      
-      size=buffer.remain() ;
-      MPI_Put(&size, SIZE_BUFFER_SIZE, MPI_CHAR, rank, OFFSET_BUFFER_SIZE, SIZE_BUFFER_SIZE, MPI_CHAR, window_) ;
-      MPI_Put(buffer.ptr(),buffer.remain(), MPI_CHAR, rank, OFFSET_BUFFER, buffer.remain(), MPI_CHAR, window_) ;
-      MPI_Win_unlock(rank, window_) ;
-      
-    }
-
-    template< typename T >
-    void popFromSharedWindow(int rank, T* object, void (T::*dumpIn)(CBufferIn&) ) 
-    {
-      size_t size ;
-      MPI_Win_lock(MPI_LOCK_SHARED, rank, 0, window_) ;
-      MPI_Get(&size, SIZE_BUFFER_SIZE, MPI_CHAR, rank, OFFSET_BUFFER_SIZE, SIZE_BUFFER_SIZE, MPI_CHAR, window_) ;
-      MPI_Win_flush(rank,window_) ;
-      CBufferIn buffer(size) ;
-      MPI_Get(buffer.start(), size, MPI_CHAR, rank,OFFSET_BUFFER, size, MPI_CHAR, window_) ;
-      MPI_Win_flush(rank,window_) ;
-      (object->*dumpIn)(buffer) ;
-      
-      size=buffer.remain() ;
-      MPI_Put(&size, SIZE_BUFFER_SIZE, MPI_CHAR, rank, OFFSET_BUFFER_SIZE, SIZE_BUFFER_SIZE, MPI_CHAR, window_) ;
-      MPI_Put(buffer.ptr(),buffer.remain(), MPI_CHAR, rank, OFFSET_BUFFER, buffer.remain(), MPI_CHAR, window_) ;
-      MPI_Win_unlock(rank, window_) ;
-      
-    }
-
-    template< typename T >
-    void popFromLockedWindow(int rank, T* object, void (T::*dumpIn)(CBufferIn&) ) 
-    {
-      size_t size ;
-      MPI_Get(&size, SIZE_BUFFER_SIZE, MPI_CHAR, rank, OFFSET_BUFFER_SIZE, SIZE_BUFFER_SIZE, MPI_CHAR, window_) ;
-      MPI_Win_flush(rank,window_) ;
-      CBufferIn buffer(size) ;
-      MPI_Get(buffer.start(), size, MPI_CHAR, rank,OFFSET_BUFFER, size, MPI_CHAR, window_) ;
-      MPI_Win_flush(rank,window_) ;
-      (object->*dumpIn)(buffer) ;
-      
-      size=buffer.remain() ;
-      MPI_Put(&size, SIZE_BUFFER_SIZE, MPI_CHAR, rank, OFFSET_BUFFER_SIZE, SIZE_BUFFER_SIZE, MPI_CHAR, window_) ;
-      MPI_Put(buffer.ptr(),buffer.remain(), MPI_CHAR, rank, OFFSET_BUFFER, buffer.remain(), MPI_CHAR, window_) ;
-      MPI_Win_flush(rank, window_) ;
+      put(&size, SIZE_BUFFER_SIZE, MPI_CHAR, rank, OFFSET_BUFFER_SIZE, SIZE_BUFFER_SIZE, MPI_CHAR) ;
+      put(buffer.ptr(),buffer.remain(), MPI_CHAR, rank, OFFSET_BUFFER, buffer.remain(), MPI_CHAR) ;
+      flush(rank) ;
     }
 
     ~CWindowManager()
     {
-      MPI_Win_free(&window_) ;
     }
   } ;
