Subj : Re: pthreads - cancellation To : comp.programming.threads From : plinius Date : Mon Aug 22 2005 12:07 pm > > 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()? > Yes I know, but I suppose not everyone knows of MPI, and tried to (maybe it didn't worked...) simplify my problem to the strict necessary... > > 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 > } > Yes, that's a good idea, but I have to restart allmost never (in 0,001 % of the cases...), and would like to be able to split the "restart-code" from the rest. But I think I'll go for your solution indeed > 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? Red this on a question in "experts-exchange.com" (a forum), and I believed it... > > > 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. .