title: why does my program hang when I use MPI_Send and MPI_Recv?
body: <p>There is a simple communication program that I used in MPICH2. when I execute the program by using </p>
  
  <pre><code>mpiexec.exe -hosts 2 o00 o01  -noprompt mesajlasma.exe
  </code></pre>
  
  <p>The program starts but does not end. I can see it is still running on the host computer "o01" by using resource monitor program. When I press <kbd>CTRL + c</kbd>, it is ended. Then I can see that my program ran properly</p>
  
  <p>Why doesn't my program end. Where does it stuck? why does my program hang when I use MPI_Send and MPI_Recv?</p>
  
  <p>Thanks in advance</p>
  
  <pre class="lang-c prettyprint-override"><code>// mesajlasma.cpp
  
  #include "stdafx.h"
  #include "string.h"
  #include "mpi.h"
  
  int main(int argc, char* argv[])
  {
  
      int  nTasks, rank;
      char mesaj[20];
      MPI_Status status;
  
      MPI_Init(&amp;argc,&amp;argv);
      MPI_Comm_size(MPI_COMM_WORLD,&amp;nTasks);
      MPI_Comm_rank(MPI_COMM_WORLD,&amp;rank);
  
      //printf ("\nNumber of threads = %d, My rank = %d\n", nTasks, rank);
  
      if(rank == 1)
      {
          strcpy_s(mesaj, "Hello World");
          if (MPI_SUCCESS==MPI_Send(mesaj, strlen(mesaj)+1, MPI_CHAR, 0, 99, MPI_COMM_WORLD)) printf("_OK!_\n");
      }
  
  
      if(rank == 0)
      {
          MPI_Recv(mesaj, 20, MPI_CHAR, 1, 99, MPI_COMM_WORLD, &amp;status);
          printf("Received Message:%s\n", mesaj);
      }
  
      MPI_Finalize();
  
      return 0;
  }
  </code></pre>