Shared memory and memory context question

Поиск
Список
Период
Сортировка
От richard@playford.net
Тема Shared memory and memory context question
Дата
Msg-id 200602051404.00089.richard@playford.net
обсуждение исходный текст
Ответы Re: Shared memory and memory context question  (Martijn van Oosterhout <kleptog@svana.org>)
Re: Shared memory and memory context question  (Doug McNaught <doug@mcnaught.org>)
Re: Shared memory and memory context question  (Neil Conway <neilc@samurai.com>)
Список pgsql-hackers
Dear all,

I am writing a C-language shared-object file which is dynamically linked with 
postgres, and uses the various SPI functions for executing queries from 
numerous trigger functions.

My question is thus: what is the best method for a dynamically linked object 
to share memory with the same object running on other backends? Am I right in 
thinking that if I allocate memory in the "upper execution context" from 
SPI_palloc(), this is not shared with the other processes?

I thought of a few ways of doing this (please forgive me if these appear 
idiotic, as I am fairly new to postgres):

1. Change memory context to TopMemoryContext and palloc everything there. 
(However, I believe this still isn't shared between processes?)

2. Use the shmem functions in src/backend/storage/ipc/shmem.c to create a 
chunk of shared memory and use this (Although I would like to avoid writing 
my own memory manager to carve up the space).

3. Somehow create shared memory using the shmem functions, and set a memory 
context to live *inside* this shared memory, which my trigger functions can 
then switch to. Then use palloc() and pfree() without worrying..

Please let me know if this problem has been solved before, as I have searched 
through the mailing lists and through the source, but am not sure which is 
the best way to resolve it. Thanks for your help.

Regards,

Richard


В списке pgsql-hackers по дате отправления:

Предыдущее
От: "Magnus Hagander"
Дата:
Сообщение: Re: [ADMIN] Postgres 8.1.x and MIT Kerberos 5
Следующее
От: Martijn van Oosterhout
Дата:
Сообщение: Re: Shared memory and memory context question