Boost Interprocess condition variables

Hi! I'm using condition variables of Boost.interprocess 1.36.0 to manage a synchronized access to a shared memory segment by two tasks. I found a problem when: task 1 is waiting on a condition variable and task 2 crashes during his execution, so task 1 waits forever on that variable. How can I kill also task 1? thank you, Federico

On Fri, Jan 09, 2009 at 10:06:00AM +0100, Federico Golfrè Andreasi wrote:
Hi!
I'm using condition variables of Boost.interprocess 1.36.0 to manage a synchronized access to a shared memory segment by two tasks. I found a problem when: task 1 is waiting on a condition variable and task 2 crashes during his execution, so task 1 waits forever on that variable.
How can I kill also task 1?
On UNIX, process 1 should get SIGCHLD when process 2 terminates in any way. The signal should interrupt waiting on the condition variable. By installing the appropriate signal handler, you can terminate process 1. I'm not sure how to do this under Windows.

Thank you for your answer,
but process 2 is not a child of process 1, and so SIGCHLD is not send.
Infact process 2 is executed from process 1 using an MPI routine
called MPI_Comm_spawn.
Do you see other approach I can try?
thank you.
2009/1/9 Zeljko Vrba
On Fri, Jan 09, 2009 at 10:06:00AM +0100, Federico Golfrè Andreasi wrote:
Hi!
I'm using condition variables of Boost.interprocess 1.36.0 to manage a synchronized access to a shared memory segment by two tasks. I found a problem when: task 1 is waiting on a condition variable and task 2 crashes during his execution, so task 1 waits forever on that variable.
How can I kill also task 1?
On UNIX, process 1 should get SIGCHLD when process 2 terminates in any way. The signal should interrupt waiting on the condition variable. By installing the appropriate signal handler, you can terminate process 1. I'm not sure how to do this under Windows.
_______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users

On Sat, Jan 10, 2009 at 11:45:03AM +0100, Federico Golfrè Andreasi wrote:
Infact process 2 is executed from process 1 using an MPI routine called MPI_Comm_spawn.
Unless MPI_Comm_spawn is doing something out of the ordinary, then process 2 is a direct child of process 1. You can verify whether this is the case by executing "ps axl" and comparing PID and PPID (parent process) for the two processes. If the signal is not delivered, then the MPI library has probably arranged that it be blocked / ignored. Try the following: right after calling MPI_Init in the parent, use sigprocmask() to explicitly unblock SIGCHLD signal and use sigaction() to install the signal handler. Otherwise, try finding a supported way of doing this, e.g., by asking on a mailing list dedicated to your MPI implementation.

I generally handle this by having another thread keep "references" to all the condvars and one part of that thread's reconfigure()/terminate() job is to signal all the condvars. Those threads that were waiting on the condvars then notice that a reconfigure_/terminate_ bool is set and proceed accordingly... Zeljko Vrba wrote:
On Sat, Jan 10, 2009 at 11:45:03AM +0100, Federico Golfrè Andreasi wrote:
Infact process 2 is executed from process 1 using an MPI routine called MPI_Comm_spawn.
Unless MPI_Comm_spawn is doing something out of the ordinary, then process 2 is a direct child of process 1. You can verify whether this is the case by executing "ps axl" and comparing PID and PPID (parent process) for the two processes. If the signal is not delivered, then the MPI library has probably arranged that it be blocked / ignored.
Try the following: right after calling MPI_Init in the parent, use sigprocmask() to explicitly unblock SIGCHLD signal and use sigaction() to install the signal handler.
Otherwise, try finding a supported way of doing this, e.g., by asking on a mailing list dedicated to your MPI implementation.
_______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users
participants (3)
-
Federico Golfrè Andreasi
-
Russell L. Carter
-
Zeljko Vrba