Re: Question about SHM_QUEUE

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Alvaro Herrera <alvherre(at)commandprompt(dot)com>
Cc: ITAGAKI Takahiro <itagaki(dot)takahiro(at)oss(dot)ntt(dot)co(dot)jp>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: Question about SHM_QUEUE
Date: 2007-04-11 14:04:14
Message-ID: 13869.1176300254@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Alvaro Herrera <alvherre(at)commandprompt(dot)com> writes:
> ITAGAKI Takahiro wrote:
>> Hmmm, my next question is whether we should use SHM_QUEUE or not in
>> new modules. The point deluded me when I wrote DSM and I wondered
>> the autovacuum-multiworkers patch uses SHM_QUEUE.

> Good question. I used SHM_QUEUE because I just believed the comments
> that said that ShmemBase would be different on each process, and so
> using plain pointers would not work. I admit I didn't even try. So if
> the list can be implemented in a different way, I have no problem with
> changing that code -- but then, if there's no practical problem with it
> I feel uninclined to continue messing with the patch until it's
> committed.

The main disadvantage of converting pointers to SHMEM_OFFSETs is that
it reduces the compiler's ability to help you find mistakes (ie,
treating a pointer to X as a pointer to Y). So I'd encourage people
to use plain pointers in new code. But I don't feel a compulsion to
convert existing code. Also, in a situation where you'd be writing
"void *" (eg, a generic linked-list type...) there's just no gain in
protection anyway.

regards, tom lane

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Andrew Dunstan 2007-04-11 14:08:36 Re: Vista/IPv6
Previous Message Peter Eisentraut 2007-04-11 13:51:00 Re: Vista/IPv6