title: Using mutexes/semaphores with processes
body: <p>Almost all the code and tutorials that I have read online so far involve using mutexes and semaphores for synchronisation amongst threads. Can they be used to synchronise amongst processes?</p>
  
  <p>I'd like to write code that looks like this:</p>
  
  <pre><code>void compute_and_print() {
     // acquire mutex
     // critical section
     // release mutex
  }
  
  void main() {
  int pid = fork();
  if ( pid == 0 ) {
    // do something
    compute_and_print();
  }
  else {
    // do something
    compute_and_print();
  }
  }
  </code></pre>
  
  <ul>
  <li>Could someone point me towards similar code that does this? </li>
  <li>I understand that different processes have different address spaces, but I wonder if the above would be different address spaces, however, wouldn't the mutex refer to the same kernel object?</li>
  </ul>