[...]
Humm... Well, it looks like I have to use a manager process. I don't think
there is any other clean method for detecting and recovering from
TerminateProcess. Okay, that's fine. Now, I need to think about efficient
means of maintaining coherency when process get terminated in the middle of
a critical-section. Windows process level mutexs have the WAIT_ABANDONDED
state. The following threads deals with some of this:
http://groups.google.com/group/comp.programming.threads/msg/94f2a233bd65bf8a
http://groups.google.com/group/comp.programming.threads/browse_frm/thread/b5775d...
(read all...)
Basically, you keep a version number in the critical-section in order to
detect different "levels" of coherent data. Something like:
lock();
// see if we need to recover from a disaster!
if (version != 3) {
if (version > -1 && version < 3) {
// perform recovery
switch (version) {
case 0:
case 1:
case 2:
}
} else {
// the version is trashed! Something very bad happened!
abort();
}
}
// zero version
// membar
--------------------------------------
// perform action 1
--------------------------------------
// membar
// inc version
--------------------------------------
// perform action 2
--------------------------------------
// membar
// inc version
--------------------------------------
// perform action 3
--------------------------------------
// membar
// inc version
assert(version == 3);
unlock();
Any suggestions?