pfSharedMem(3pf) OpenGL Performer 3.2.2 libpr Reference Pages
NAME
pfInitArenas, pfFreeArenas, pfGetSharedArena, pfGetSemaArena,
pfSharedArenaSize, pfGetSharedArenaSize, pfSharedArenaBase,
pfGetSharedArenaBase, pfSemaArenaSize, pfGetSemaArenaSize,
pfSemaArenaBase, pfGetSemaArenaBase, pfTmpDir, pfGetTmpDir - Shared
Memory Functions
FUNCTION SPECIFICATION
#include <Performer/pr.h>
int pfInitArenas(void);
int pfFreeArenas(void);
void* pfGetSharedArena(void);
void* pfGetSemaArena(void);
void pfSharedArenaSize(size_t size);
size_t pfGetSharedArenaSize(void);
void pfSharedArenaBase(void *base);
void * pfGetSharedArenaBase(void);
void pfSemaArenaSize(size_t size);
size_t pfGetSemaArenaSize(void);
void pfSemaArenaBase(void *base);
void * pfGetSemaArenaBase(void);
void pfTmpDir(char *dirname);
const char * pfGetTmpDir(void);
DESCRIPTION
pfInitArenas creates arenas that can be used to allocate shared memory,
locks and semaphores from (see pfMalloc, usnewlock, usnewsema). In a
libpf application, this function is called by pfInit so it is not
necessary to call it directly. However, a libpr application that wishes
to use Performer's arenas, must call pfInitArenas before calling pfInit
to ensure that the type system is created in shared memory.
In addition to creating a shared memory arena, pfInitArenas uses usinit
to create an arena for locks and semaphores.
pfTmpDir and the environment variable PFTMPDIR control where pfInitArenas
creates its arenas. If neither is specified, the semaphore arena is
created in /usr/tmp and the shared memory arena is created in /dev/zero
Page 1
pfSharedMem(3pf) OpenGL Performer 3.2.2 libpr Reference Pages
(swap space). If a temporary directory is specified, then files are
created in that directory for the shared memory and semaphore arenas.
Both these files are unlinked so that they are removed from the file
system when the process terminates. Once created, these arenas cannot
grow beyond the specified size, so OpenGL Performer tries to create a
large (256MB by default) shared memory arena and a 128KB semaphore arena.
The semaphore arena always uses a memory mapped file.
For the shared memory arena, the default option uses swap space. This is
usually preferable to using a memory mapped file in a directory specified
by PFTMPDIR. Using an actual file is slower at allocation time and
requires actual disk space for extending the file length to equal the
amount of memory allocated (pfMalloc) from the arena. Because the
temporary file is unlinked after creation, any memory actually allocated
will show up as used under df(1), but not under du(1). The application
size in ps(1) will reflect the maximum specified size of the arena, e.g.
256MB. But space is not reserved until accessed, i.e. until required by
pfMalloc. So the large arena created by pfInitArenas does not consume
any substantial disk or swap space resources until needed.
pfSharedArenaSize can be used to override the arena size that OpenGL
Performer uses by default (256MB). size specifies the desired size in
bytes. Arena size is limited by the largest contiguous possible memory
mapping, currently slightly more than 1.7GB in an application linked with
DSOs. When attempting large arena mappings, first make sure that the
real and virtual memory usage limits set in the shell or with setrlimit()
are adequate. pfSharedArenaSize must be called before pfInitArenas to
have effect. pfGetSharedArenaSize returns the arena size in bytes.
The comparable calls for the semaphore arena are pfSemaArenaSize and
pfGetSemaArenaSize.
pfSharedArenaBase sets the base address for the mapping of the shared
memory arena. Normally, IRIX chooses these base addresses automatically.
Direct specification is only useful if the application needs closer
control over the layout of virtual address space, e.g. to avoid conflicts
with other mappings. pfGetSharedArenaBase returns the base address for
the arena.
The comparable calls for the semaphore arena are pfSemaArenaBase and
pfGetSemaArenaBase.
pfGetSemaArena returns a handle to the lock arena and pfGetSharedArena
returns a pointer to the shared memory arena. This pointer cannot be
used directly, only as an argument to pfMalloc. pfGetTmpDir returns the
temporary directory set using pfTmpDir.
NOTES
Shared Arena functionality is not currently supported under the single
processor version of Performer on Linux.
Page 2
pfSharedMem(3pf) OpenGL Performer 3.2.2 libpr Reference Pages
These arenas can only be used by related processes. Related in this
context means processes that are created by fork or sproc once
pfInitArenas has been called. Use pfDataPool for sharing memory between
unrelated processes. pfInitArenas should be called before any fork calls
are made.
SEE ALSO
acreate, pfFree, pfMalloc, usinit, usnewlock, usnewsema
Page 3