Re: C++ threads & signals



neilsolent <nh@xxxxxxxxxxxxxxxxxxxxxx> writes:
See, you know that this isn't possible (otherwise, you would hardly
have constructed in this way), I know that this isn't possible and I
know that you know that.

But it IS possible.

Well, trivially, a programmable general purpose computer can be
programmed to do anything, even Haskell :->. Eg, when viewing a
message queue as an abstract object, it should be obvious that there
are striking similarities to datagram sockets and a lot of 'internet'
amply demonstrates that bytestream-oriented virtual circuits can be
used for record-/ message-based communication.

What I am trying to tell you is that the
question is as stupid as asking 'how does one fork a process on
Windows'. 'fork' is not a primitive supplied by this environment,
hence, a problem which could be solved very easily by forking on
UNIX(*), eg run a supervisor process which is capable of reliably
monitoring another process and restart it, should it die prematurely,
will necessarily have a different solution there and possibly no
satisfactory solution at all.

I think you miss the point.
You can do the EQUIVALENT of fork() on Windows. You call CreateProcess
() and monitor handles. This does the ESSENTIAL work of creating a
child process, and monitoring it.

There is no equivalent of fork on Windows, except as incomplete
emulation and that you consider the functionality which is available
on Windows more essential than the one which is missing may seem
natural for you, BUT IT IS NOT NATURAL FOR ME. Did this come across
this time? 'fork' creates a new process which continues to execute the
same program the process which called fork executed. While this can be
emulated (to some degree) via 'CreateProcess' + some weird *** for
most actual use cases (see remark about programmability above), this
does not demonstrate that it would be identical to 'Windows API call +
some weird ***'.

For this particular case, it is necessary to deal with two independent
programs whith a certain relation to each other. That's a complication
which is not needed on UNIX(*), because it is sufficient to use one
program, a la

while (1) {
if (fork() == 0) break;
wait();
}

/*
actually working code starts here
*/

NB: This is a minimal example and not a Ph.D.-thesis trying to
become commercial.

In a similar spirit, the Windows-API offers functionality not avaiable
on UNIX(*) and the existence of this functionality leads to programs
designed to use it in order to accomplish some purpose. The fact that
such a design has limited, if any, possibilities for reuse elsewhere,
except when using suitable auxiliary software, just means that it
is essentially non-portable. Big deal.
.