Re: Shared Memory

New Message Reply Date view Thread view Subject view Author view

Fischler (src++at++rose)
Mon, 22 May 1995 17:04:48 -0700


+>---- On May 22, 4:43pm, Darin C. Partridge wrote:
> Subject: Shared Memory
->The following code can be found in generic.c:
->
->*******************************************************
->
->/* Get pointer to shared memory malloc arena created by pfInit()*/
-> arena = pfGetSharedArena();
->
-> /*
-> * Malloc structures now, before pfConfig(), so forked processes have same
-> * pointers.
-> */
-> ViewState = (SharedViewState *) pfCalloc(1, sizeof(SharedViewState),
->arena);
->
->*******************************************************
->
->My question is, can I get a pointer to "ViewState" from a completely
->unrelated process. I want to run a completely seperate process that can
->monitor/update items in this structure.

This is exactly the situation that pfDataPools exist for.
Look at the pfDataPool man page.

You will allocate your ViewState structure with a set ID
out of a named pfDataPool.
Unrelated processes will be able to attach to the pfDataPool,
find the item with the known ID, and then read/write it.
Locking facilities exist for all ID-ed items in a pfDataPool.

For a detailed example, you can look in
        /usr/src/Performer/src/lib/libpfutil
The GUI and input handling utilities use a data pool for their shared data.
The data pool is created in shmem.c and in gui.c the getGUIDataPool()
routine attaches to the GUI data pool.

src.

-- 
-----{-----{---++at++   -----{----{---++at++   -----{----{---++at++   -----{----{---++at++
Sharon Rose Clay (Fischler) - Silicon Graphics, Advanced Graphics Dev.
src++at++sgi.com  (415) 390 - 1002  FAX: (415) 965 - 2658  MS 8U-590
-----{-----{---++at++   -----{----{---++at++   -----{----{---++at++   -----{----{---++at++

New Message Reply Date view Thread view Subject view Author view

This archive was generated by hypermail 2.0b2 on Mon Aug 10 1998 - 17:51:30 PDT

This message has been cleansed for anti-spam protection. Replace '++at++' in any mail addresses with the '@' symbol.