Claudio Natoli wrote:
> > A thought there. If we go with the "select loop" version you had
> > out and just poll (select() with short timeout, poll, loop..), do we
> > actually *need* the APCs *at all*? Or should we go with a
> > solution? (With signals delivered on a separate thread as we
> > of course) The only advantage we gain by the APCs is that they will
> > the "Ex functions", no? (It's not much extra code to put it in
> > but if we don't need it..)
> Hmmm, not sure. Possibly we can, although it depends on where else we
> end up needing to "wait". I'd be unreluctant to undo your good work on
> until we are sure it is safe to...
There are a couple advantages to using QueueUserAPC for the signal
delivery. There are two alternatives that I see, SignalObjectAndWait,
and a looping array index.
The problem with SignalObjectAndWait is that it a. does not queue (all
waiting threads released at once) and b. has more complicated threading
issues...so I would tend to discount this option. If it was necessary
to queue the signals FIFO, we would have to set up the FIFO stack.
A looping array counter is better, because now everything important runs
in the main thread. Basically, during each poll the backend runs a
tight loop inside a critical section to check if there are any pending
signals. In fact, this is slightly faster that a WaitForSignalObjectEx,
but involves more code.
That's the crucial point for me: QueueUserAPC is simpler; most of the
signal utility routines will be just a couple lines of code. This will
make debugging less of a pain and be easier to test. Plus, the OS will
do the queuing, which is the most vulnerable part of the code to bugs
and other problems...no loops! My intuition tries to keep me away from
loops wherever possible.
pgsql-hackers-win32 by date
|Next:||From: Magnus Hagander||Date: 2004-01-16 13:53:31|
|Subject: Re: Win32 signal code - first try|
|Previous:||From: Claudio Natoli||Date: 2004-01-16 00:29:12|
|Subject: Re: Microsoft releses Services for Unix|