[mpich-discuss] MPI_Comm_connect and MPI_Comm_accept running simultaneously
toufik hadjazi
h_toufik7 at hotmail.fr
Sat Aug 25 03:59:00 CDT 2012
Hi you all,
I'm working on a client server application, the architecture of the server and the client is pretty much the same; the scheme is : each application have three threads (receiver, worker and sender), the only difference between the two applications is in the worker thread(the processing), when I run only the two threads, the worker and (reciever or sender), it works fine, but when I start the third one, the program hangs on the instruction "MPI_Comm_connect" or "MPI_Comm_accept" with no error message just it indicates that "client.exe has stopped working".I'm wondering if the problem is in "MPI_Comm_connect" and "MPI_Comm_accept" running in the same time, I thought that maybe when a thread is blocking on one of those functions, we can't switch to another thread even if his quantum is done. is it true? and is these functions can be interrupted safely?P.S: I'm working with Visual C++ and QT.
the sender Thread:while(true)
{
// wait up for a new message
printf("receiver thread : waiting for connections...\n"); fflush(stdout);
MPI_Comm_accept(localPort, MPI_INFO_NULL, 0, MPI_COMM_SELF, &client); MPI_Recv(&message, 1, MessageType, MPI_ANY_SOURCE, MPI_ANY_TAG, client, &status); //insert the message into the fifo
DIH.InFifo.Insert(message);
printf("A messaage has been received\n"); fflush(stdout); //disconnect from the current client
MPI_Barrier(client);
MPI_Comm_disconnect(&client);
} the sender Thread:while(true)
{
message = DIH.OutFifo.Mov(); // send a new message
printf("Sender thread trying to connect to port <%s>...\n", port); fflush(stdout);
MPI_Comm_connect(port, MPI_INFO_NULL, 0, MPI_COMM_SELF, &client); MPI_Send(&message, 1, MessageType, 0, 0, client); //insert the message into the fifo
printf("the messaage has been sent\n"); fflush(stdout); //disconnect from the current client
MPI_Barrier(client);
MPI_Comm_disconnect(&client);
} the worker Thread:while(true)
{
message = DIH.InFifo.Mov();
printf("worker thread gonna treat a new message...\n"); fflush(stdout); switch (message.Command)
{
case Insertion :
{
printf("\ninsertion running...\n"); fflush(stdout);
sleep(1);
}
break;
case Suppression:
break;
case ExactMatchQuery:
break;
case RangeQuery:
break;
default:
printf("command not recognized!\n");
} DIH.OutFifo.Insert(message);
}
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/mpich-discuss/attachments/20120825/04b6fbfb/attachment.html>
More information about the mpich-discuss
mailing list