Skip site navigation (1) Skip section navigation (2)

Re: Win32 signal code - first try

From: "Merlin Moncure" <merlin(dot)moncure(at)rcsonline(dot)com>
To: "Claudio Natoli" <claudio(dot)natoli(at)memetrics(dot)com>
Cc: "pgsql-hackers-win32 " <pgsql-hackers-win32(at)postgresql(dot)org>,"Magnus Hagander" <mha(at)sollentuna(dot)net>
Subject: Re: Win32 signal code - first try
Date: 2004-01-16 13:38:36
Message-ID: 303E00EBDD07B943924382E153890E5434AA61@cuthbert.rcsinc.local (view raw or flat)
Thread:
Lists: pgsql-hackers-win32
Claudio Natoli wrote:
> > A thought there. If we go with the "select loop" version you had
tried
> > out and just poll (select() with short timeout, poll, loop..), do we
> > actually *need* the APCs *at all*? Or should we go with a
pure-polling
> > solution? (With signals delivered on a separate thread as we
discussed,
> > of course) The only advantage we gain by the APCs is that they will
stop
> > the "Ex functions", no? (It's not much extra code to put it in
there,
> > but if we don't need it..)
> 
> Hmmm, not sure. Possibly we can, although it depends on where else we
> might
> end up needing to "wait". I'd be unreluctant to undo your good work on
> this
> 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.

Merlin



pgsql-hackers-win32 by date

Next:From: Magnus HaganderDate: 2004-01-16 13:53:31
Subject: Re: Win32 signal code - first try
Previous:From: Claudio NatoliDate: 2004-01-16 00:29:12
Subject: Re: Microsoft releses Services for Unix

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group