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

Re: Can we simplify win32 threading code

From: "Magnus Hagander" <mha(at)sollentuna(dot)net>
To: "Qingqing Zhou" <zhouqq(at)cs(dot)toronto(dot)edu>,<pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Can we simplify win32 threading code
Date: 2005-05-26 14:12:12
Message-ID: 6BCB9D8A16AC4241919521715F4D8BCE6C7559@algol.sollentuna.se (view raw or flat)
Thread:
Lists: pgsql-hackers
> Currently PG win32 port mainly does the following to simulate signals:
> 
> (*) the process who kill the signal:
>  - put the signal in a named pipe, then it is done;
> 
> (*) the process who should receive the signal:
>  - a non-stop thread "pg_signal_thread" will read the signal 
> from the pipe, and start another thread 
> "pg_signal_dispatch_thread", which puts the signal in a local 
> memory variable "pg_signal_queue" and 
> SetEvent(local_memory_event_variable);
>  - the main thread of this process could be awakened by the 
> event from waiting status(like semop()) or 
> CHECK_FOR_INTERRUPTS() actively;
> 
> 
> Could we simplify this process like this:
> 
> (*) the process who kill the signal:
>  - put the signal in a *shared memory variable 
> pg_signal_queue* and 
> SetEvent(*shared_memory_event_variable*), then it is done;
>
> (*) the process who should receive the signal:
>  - the main thread of this process could be awakened by the 
> event from waiting status(like semop()) or 
> CHECK_FOR_INTERRUPTS() actively; -- there is no other threads 
> of this process;
> 
> Any show-stop reasons of not doing this?

Yeah, that should work. With one shared memory segment and one event for
each process, of course. The event can be the same one as is used now,
only it has to be named so it can be accessed externally.

It would do away with the thread, certainly. But it's not quite as
simple as you outline above - you'll need to replace the critical
section locking (easy, lightweight) with a mutex or something like that
(more complex, more heavy weight). But probably named pipes is more
heavy, yes.

You'll also need some way of delivering the feedback, I think - kill(0)
is supposed to tell you if there is a live process in th eother end, so
you can't just throw the signal out and hope for the best.

I think the named pipe parts of things is a leftover from back when we
were using APCs to interrupt the main thread - which required a separate
thread. But since we can't do that, this sounds like a reasonable
simplification.

//Magnus

Responses

pgsql-hackers by date

Next:From: Neil ConwayDate: 2005-05-26 14:15:07
Subject: Re: O_DIRECT for WAL writes
Previous:From: Peter EisentrautDate: 2005-05-26 14:00:23
Subject: Re: soundex and metaphone

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