title: Linux inter-process reentrant semaphore
body: <p>I'm porting a Windows application to Linux and I have a synchronization problem.</p>
  
  <p>In Windows I'm using a system-level named mutex to sync access to a shared memory block.</p>
  
  <p>How do I emulate that in Linux? I've created a SystemV semaphore, using semget. The problem is that it is not reentrant, if I already hold it it will block, unlike on Windows. I could add a reference count to it, but then I would need to synchronize access to that, which means another (this time for the current process only) mutex.</p>
  
  <p>Is there a class somewhere which provides a reentrant interprocess lock (maybe in Boost)?</p>
  
  <p>BTW, using a file lock is not acceptable since it will probably be too slow (I need ultra-low latency communication between the two processes).</p>