title: How to use shared memory in python and C/C++
body: <p>I am trying to modify a python program to be able to communicate with a C++ program using shared memory. The main responsibility of the python program is to read some video frames from an input queue located in shared memory, do something on the video frame and write it back to the output queue in shared memory.</p>
  
  <p>I believe there are few things I need to achieve and it would be great if someone can shed some light on it:</p>
  
  <ol>
  <li><p><strong>Shared memory:</strong> In C/C++, you can use functions like <code>shmget</code> and <code>shmat</code> to get the pointer to the shared memory. What is the equivalent way to handle this in python so both python and C++ program can use the same piece of shared memory?</p></li>
  <li><p><strong>Synchronization</strong>: Because this involves multi-processing, we need some sort of locking mechanism for the shared memory in both C++ and python programs. How can I do this in python?</p></li>
  </ol>
  
  <p>Many thanks!</p>