Re: shared memory allocation - C function

From: Michael Paquier <michael(dot)paquier(at)gmail(dot)com>
To: Alan Nilsson <anilsson(at)apple(dot)com>
Cc: "pgsql-general(at)postgresql(dot)org" <pgsql-general(at)postgresql(dot)org>
Subject: Re: shared memory allocation - C function
Date: 2014-04-17 04:56:05
Message-ID: CAB7nPqR+S-kb8BxJ+nR2+XcKYX-usjpSGsSRtY9NqSsqL2tJKw@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Thu, Apr 17, 2014 at 8:04 AM, Alan Nilsson <anilsson(at)apple(dot)com> wrote:

> Is it possible to allocate a small chunk of shared memory outside of any
> pools(i.e. manually alloced & de-alloced) that is visible to all processes?
> I would like a small amount to store a mutex and a condition variable that
> is accessible in a c function from any process. Is there an SPI/API to do
> this?
>
You can allocate a custom amount of shared memory at server initialization
using the hook called shmem_startup_hook in ipci.c through a library loaded
with shared_preload_libraries. Why not having a look at
contrib/pg_stat_statements which is a good example?
--
Michael

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Alban Hertroys 2014-04-17 06:55:35 Re: Re: any way for a transaction to "see" inserts done earlier in the transaction?
Previous Message Adrian Klaver 2014-04-17 02:32:06 Re: any way for a transaction to "see" inserts done earlier in the transaction?