title: Visibility of change to shared memory from shm_open() + mmap()
body: <p>Let's say I am on CentOS 7 x86_64 + GCC 7.</p>
  
  <p>I would like to create a ringbuffer in shared memory.</p>
  
  <p>If I have two processes Producer and Consumer, and both share a named shared memory, which is created/accessed through shm_open() + mmap().</p>
  
  <p>If Producer writes something like:</p>
  
  <pre><code>struct Data {
  uint64_t length;
  char data[100];
  }
  </code></pre>
  
  <p>to the shared memory at a random time, and the Consumer is constantly polling the shared memory to read.  Will I have some sort of synchronization issue that the member length is seen but the member data is still in the progress of writing?  If yes, what's the most efficient technique to avoid the issue?</p>
  
  <p>I see this post:
  <a href="https://stackoverflow.com/questions/22207546/shared-memory-ipc-synchronization-lock-free">Shared-memory IPC synchronization (lock-free)</a></p>
  
  <p>But I would like to get a deeper, more low level of understanding what's required to synchronize between two processes efficiently.</p>
  
  <p>Thanks in advance!</p>