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-06-01 08:57:26
Message-ID: (view raw, whole thread or download thread mbox)
Lists: pgsql-hackers
> I have simplified the code according to the discussion. Now 
> there is no pipe or signaling threads, process access shared 
> memory directly to pass signals.
> Seems everything works fine except pg_ctl. I now have two 
> choices to fix it:
> (1) Record Shared memory name (it is already there) and the 
> offset of signaling shared memory in; So the 
> pg_ctl program can access the shared memory (since it has 
> write down the signal number there) and SetEvent target process;

Why not just use the pid in teh name, and have one segment per backend?
Remember on Win32 having a couple of hundred shared memory segments is
not a problem. (I assume you are creating these using MapViewOfFile()
etc, and not using the shmget() emulators)

Then if I want to kill pid 1234 I just do:
mtx = OpenMutex(..,"pqsignalmtx1234");
m = OpenFileMapping(...,"pqsignal1234");
v = MapViewOfFile();
-- write signal number --
e = OpenEvent(..,"pqsignalevt1234");

(pseudo-code. You'll need to look for deadlocks in the event processor,
but it should be fairly easy to write code that won't deadlock)

> (2) Postmaster will startup a thread monitoring messages, 
> pg_ctl simulate "kill" by sending postmaster a message 
> <target_pid, signum>, then postmaster will forward this 
> "signum" to "target_pid";

I don't like that. If the postmaster dies, how will you signal the
remaining backends? The signal processing has to take place in the
actual backend affected, and only there. But that should be no problem
with the solution I outlined above.

This way you'll also be able to pg_kill a process without knowing where
the file is, which at least I would expect. Needing to
specify the full data path just to run pg_kill is not good.



pgsql-hackers by date

Next:From: Mark Cave-AylandDate: 2005-06-01 09:27:41
Subject: Re: Cost of XLogInsert CRC calculations
Previous:From: Simon RiggsDate: 2005-06-01 08:50:09
Subject: Re: Cost of XLogInsert CRC calculations

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