What is the performance of boost :: interprocess_mutex vs native Win32 mutexes?

Please note that I can do research inside the acceleration source code and do this to answer my own curiosity if there is no one with the answer.

I really ask because maybe someone has already made this comparison and can answer authoritatively?

It would seem that creating a file with the display of shared memory between processes, and when building with the help of InterlockedIncrement()it, you can create a mutex mostly usermode, similar to CRITICAL_SECTION, which will be much more efficient than Win32 Mutex for interprocess synchronization.

So, I expect that it can probably be implemented in Win32 boost::interprocess_muteximplementation this way, and for him it will be much faster than the proposed API.

However, I have an assumption, I do not know, through field testing, that performance boost::interprocess_mutexfor interprocess synchronization or its implementation is deeply investigated.

Does anyone have experience using or profiling their relative performance, or can they comment on the use of InterlockedIncrement () security for processes using shared memory?

+3
source share
2 answers

boost 1.39.0 pthreads. ( , ). . Boost/interprocess/sync/emulation/interprocess_mutex.hpp. , lock():

inline void interprocess_mutex::lock(void)
{
   do{
      boost::uint32_t prev_s = detail::atomic_cas32(const_cast<boost::uint32_t*>(&m_s), 1, 0);

      if (m_s == 1 && prev_s == 0){
            break;
      }
      // relinquish current timeslice
      detail::thread_yield();
   }while (true);
}

, boost:: interprocess:: mutex , . , API boost:: interprocess, HANDLE , .

+3

, , InterlockedIncrement() usermode, CRITICAL_SECTION, , Win32 Mutex .

CRITICAL_SECTION . , , .

"" Interlocked , , , , , , , .

.

+1

Source: https://habr.com/ru/post/1713252/


All Articles