Re: New shared memory hooks proposal (was Re: pre_load_libraries)

From: Marc Munro <marc(at)bloodnok(dot)com>
To: pgsql-patches(at)postgresql(dot)org
Subject: Re: New shared memory hooks proposal (was Re: pre_load_libraries)
Date: 2006-07-18 23:36:04
Message-ID: 1153265764.16766.48.camel@bloodnok.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers pgsql-patches

The attached patch provides add-ins with the means to register for
shared memory and LWLocks. This greatly improves the ease with which
shared memory may be used from add-ins, while keeping the accounting and
management for that shared memory separate.

Specifically it adds named add-in shared memory contexts. From these,
memory can be allocated without affecting the memory available in other
contexts.

Usage is as follows:
from add-in functions called from preload_libraries, you may call
RegisterAddinContext(const * name, size_t size)
to register a new (logical) shared memory segment.

and
RegisterAddinLWLock(LWLockid *lock_ptr);
to request that a LWLock be allocated, placed into *lock_ptr.

The actual creation of the shared memory segment and lwlocks is
performed later as part of shared memory initialisation.

To allocate shared memory from a named context you would use
ShmemAllocFromContext(size_t size, const char *name);

To reset a shared memory context back to its original unused state (from
which new allocations may be performed), you may use
ShmemResetContext(const char *name);

This works for me (for Veil) and make check runs fine.

I have not included any documentation updates in the patch as I'm not
sure where such API changes should be documented.

All comments, questions and suggestions are welcomed.

__
Marc

Attachment Content-Type Size
patches text/x-patch 11.1 KB

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Matthew D. Fuller 2006-07-18 23:41:49 Re: [PATCHES] 8.2 features?
Previous Message David Fetter 2006-07-18 23:32:22 Re: [COMMITTERS] pgsql: Done: o -Display IN, INOUT, and OUT parameters in \df

Browse pgsql-patches by date

  From Date Subject
Next Message Matthew D. Fuller 2006-07-18 23:41:49 Re: [PATCHES] 8.2 features?
Previous Message Bruce Momjian 2006-07-18 22:18:07 Re: Win32 DEF file error