title: Mutual Exclusion in MPI (critical section)
body: <p>I am learning MPI and I am making a program in C to run with four processes. Each process has access to an index (n), then it adds one to that index (update) and each process must know the last calculated value of n.</p>
  
  <p>If a process is accessing the index, the rest of processes must wait until the index is released.</p>
  
  <p>In other words, each process must:</p>
  
  <p>1- access the index
  2- update the index
  3- release the index</p>
  
  <p>The 1 and 2 points are in the critical section. How can I manage the mutual exclusion with MPI? I have used MPI_Bcast to send the last calculated value and MPI_Wait but it doesn't work.</p>
  
  <p>Thanks in advance.</p>