title: difference between MAP_PRIVATE and MAP_SHARED in mmap for threads
body: <p>The content of file 'hello' is <code>hello</code>.</p>
  
  <pre><code>$ od -tx1 -tc hello 
  0000000 68 65 6c 6c 6f 0a
            h   e   l   l   o  \n
  0000006
  </code></pre>
  
  <p>Below is my code to make some changes to the file 'hello'.</p>
  
  <pre><code>static void *task();
  
  int main(void)
  {
      int *p;
      pthread_t Thread;
      int fd = open("hello", O_RDWR);
      if (fd &lt; 0) {
          perror("open hello");
          exit(1);
      }
      p = mmap(NULL, 6, PROT_WRITE, MAP_PRIVATE, fd, 0);
      if (p == MAP_FAILED) {
          perror("mmap");
          exit(1);
      }
      close(fd);
      pthread_create(&amp;Thread, NULL, &amp;task, p)
      printf("Help");
      pthread_join(Thread, 0);
      munmap(p, 6);
      return 0;
  }
  
  static void * task(int *r)
  {
   r[0] = 0x30313233;
  }
  </code></pre>
  
  <p>The code above I used <code>MAP_PRIVATE</code>, and it seems that the child thread does not work.
  If I change <code>MAP_PRIVATE</code> to <code>MAP_SHARED</code>, I see it makes the difference I expect.</p>
  
  <pre><code>$ od -tx1 -tc hello
   0000000 33 32 31 30 6f 0a
             3   2   1   0   o  \n
   0000006
  </code></pre>
  
  <p>But I have no idea how it happens.</p>