c++ - boost interprocess mutex in managed_shared_memory -


i have thread in process 1 create boost::interprocess::managed_shared_memory segment. in segment allocate boost::interprocess::deque using custom allocator , create boost::interprocess::interprocess_mutex , 2 boost::interprocess::interprocess_condition variables using default allocator. use find_or_construct method create these.

i have process (process 2) opens these using find method on boost::interprocess::managed_shared_memory segment have opened in process 2.

i understand managed_shared_memory segments have kernel or filesystem persistency , interprocess_mutex/interprocess_condition variables have process level persistency.

the scenario getting stuck.

1) process 1 starts thread creates everything.

2) process 2 starts , opens everything, @ stage shared memory , synchronization working well.

3) process 1 restarts thread tries create again (i believe shouldnt though using find_or_construct)

4) process 2 stuck on wait call condition variable though thread in process 1 has done notify.

am missing in terms of how should create shared memory , mutex/conditons or along lines of persistence? running code on windows.

consider using:

boost::interprocess::named_mutex boost::interprocess::scoped_lock<boost::interprocess::named_mutex> boost::interprocess::named_condition  

rather allocating mutexes & condition variables in existing shared memory block. boost handles lot of messy details you.

note: create these named_* objects in process space, not in shared memory. boost creates actual shared memory segments containing mutex & condition variables you.

i have had trouble trying map shared memory segment twice same process. there chance when run second instance of process1 thread attempting create new mapping while old 1 still exists?


Comments

Popular posts from this blog

plot - Remove Objects from Legend When You Have Also Used Fit, Matlab -

java - Why does my date parsing return a weird date? -

Need help in packaging app using TideSDK on Windows -