title: MPI_SendRecv deadlock on execution
body: <p>I'm trying to send information from one processor to another in a ring way from an offset processor using MPI_Sendrecv but i got deadlock. What is wrong in my code? Basically i need to use MPI_SendRecv to solve this kind of problem.</p>
  <pre><code>#include &lt;stdio.h&gt;
  #include &lt;unistd.h&gt;
  #include &lt;mpi.h&gt;
  
  int main (int argc, char *argv[])
  {
      int offset = 9;
      int size, rank, value, next, prev, sendval, recval, namelen;
      double t0, t;
      char processor_name[MPI_MAX_PROCESSOR_NAME];
      MPI_Status status;
  
      MPI_Init(&amp;argc, &amp;argv);
      MPI_Comm_size(MPI_COMM_WORLD, &amp;size);
      MPI_Comm_rank(MPI_COMM_WORLD, &amp;rank);
      MPI_Get_processor_name(processor_name, &amp;namelen);
  
      value = 5;
  
      if (size &gt; 1)
      {
          next = (rank + 1)% size;
          prev = (size+rank - 1)% size;
  
          sendval = value + rank;
  
          if (rank == offset)
          {
              MPI_Sendrecv(&amp;sendval, 1, MPI_INT, next, 1, &amp;recval, 1, MPI_INT, prev, 10, MPI_COMM_WORLD, &amp;status);
          }
          else
          {
       
              MPI_Recv(&amp;recval, 1, MPI_INT, prev, 10, MPI_COMM_WORLD, &amp;status);
              MPI_Send(&amp;sendval, 1, MPI_INT, next, 10, MPI_COMM_WORLD);
     
          }
      }
  
      MPI_Finalize();
      return 0;
  }
  </code></pre>