interprocess
interprocess copied to clipboard
boost interprocess spin wait deadlock when process crash in shared memory alloc
void yield() { //Lazy initialization of limits if( !m_k){ this->init_limits(); } //Nop tries if( m_k < (nop_pause_limit >> 2) ){
}
//Pause tries if the processor supports it
#if defined(BOOST_INTERPROCESS_SMT_PAUSE)
else if( m_k < nop_pause_limit ){
BOOST_INTERPROCESS_SMT_PAUSE
}
#endif
//Yield/Sleep strategy
else{
//Lazy initialization of tick information
if(m_k == nop_pause_limit){
this->init_tick_info();
}
else if( this->yield_or_sleep() ){
ipcdetail::thread_yield();
}
else{
ipcdetail::thread_sleep_tick();
}
}
++m_k;
}
I used try_atomic_func() which gets segment_manager as its parameter. The function will return false in case of segment is locked. BUT concurrency issues might happen in some cases (e.g when a thread is allocating while another thread is trying to find the allocated memory.
**Edited: BUT I'm looking forward to find a better solution