Subj : Re: pthreads - cancellation To : comp.programming.threads From : loic-dev Date : Mon Aug 22 2005 04:19 am Salut! > I'm using pthreads with a communication-librarie. > This librarie has blocking Recv's. MPI has also a non blocking receive MPI_Irecv(). > When a "cummunicator" (you can see it as a radio-frequency) changes, I > have to repost the Recv, Do you mean MPI Communicator here? > The Recv function is of the following form: Recv(int number, comm > communicator). MPI_Recv() has more paramaters, actually. Is it a function of your own, which in turn calls MPI_Recv()? > Hence I can't let the thread know it should be restarted with a > dummy-message, > because every possible value for "number" is valid. One possibility I see would be to extend the message. Instead of being one number, it would be a structure of the form: struct my_mesg { int number; bool restart; // true if restart message } That way, you wouldn't have any problem to recognize a restart message. This is IMHO the "best" solution (of course, "best" is always relative ;-) Another possibility would be to perform a non blocking receive with MPI_Irecv() and poll for communicator change. But this might complicate message's retrieval, and you need to poll (vs. asynchronous notification). > Also it seems that cancellation I don't know the MPI internals, but I wouldn't be surprised if deferred cancellation works. > is really tricky (and not allways possible, and never advisable). Why is it never advisable? > > Call 'shutdown' on the socket it's blocked on. > > Thanks, but the library is mpi, which doesn't has a > "shutdown"-operation... I don't know if MPI has a similar feature... But with PVM, it is possible to get the socket descriptors used for the communication. HTH, Loic. .