Thread: extension allocating shared memory

extension allocating shared memory

From
"Kevin Grittner"
Date:
What is the best way for an extension to allocate shared memory and to
access it from every backend?  Or, if there is no support existing for
that, what advice do people have if I want to make that happen?  I don't
need a lot (probably 1KB would do).
If this just "can't be done" I guess I could start a little daemon to
run alongside PostgreSQL and talk to it through a pipe or TCP on
localhost, but it seems cleaner to have it run within PostgreSQL if
feasible.
-Kevin


Re: extension allocating shared memory

From
Alvaro Herrera
Date:
Excerpts from Kevin Grittner's message of mar abr 17 16:27:21 -0300 2012:
> What is the best way for an extension to allocate shared memory and to
> access it from every backend?  Or, if there is no support existing for
> that, what advice do people have if I want to make that happen?  I don't
> need a lot (probably 1KB would do).

RequestAddinShmemSpace

--
Álvaro Herrera <alvherre@commandprompt.com>
The PostgreSQL Company - Command Prompt, Inc.
PostgreSQL Replication, Consulting, Custom Development, 24x7 support


Re: extension allocating shared memory

From
"Kevin Grittner"
Date:
Alvaro Herrera <alvherre@commandprompt.com> wrote:
> Excerpts from Kevin Grittner's message:
>> What is the best way for an extension to allocate shared memory
>> and to access it from every backend? 
> RequestAddinShmemSpace
Perfect!  That's exactly what I wanted.  I see that the
pg_stat_statements extension is already using it, so I even have a
good working example to look at.
Thanks,
-Kevin