title: memory range sharing in threads : ensure data is not stuck in cache
body: <p>When sending address of memory location from one thread to another, how to ensure that data is not stuck in CPU cache, and that the second thread actually reads the correct value ? ( I'm using a socketpair() to send the 
  pointer from one thread to another )</p>
  
  <p>And related question , how does c++ compiler, along with thread primitives, figure out what memory address need to be handled specially for synchronozations.</p>
  
  <pre><code>struct Test { int  fld; }
  
  thread_1 ( ) {
    Test *ptr1 = new Test;
    ptr1-&gt;fld = 100;
    ::write(write_fd, &amp;ptr1, sizeof(ptr1));
  }
  
  thread_2 () {
    Test *ptr2;
    ::read(read_fd, &amp;ptr2, sizeof(ptr2));
    // WHAT MAGIC IS REQUIRED TO ENSURE THIS ?
    assert(ptr2-&gt;fld == 100 );
  }
  </code></pre>