From: Stephen Jeffrey (Stephen.Jeffrey++at++maths.uq.edu.au)
Date: 04/10/2003 00:44:19
Hi,
I want to allocate data from the shared memory arena
after calling pfConfig, and then access that data in
the APP and DRAW processes. If the data in the arena
is modified in the APP process, the change is not seen
in the DRAW process. Also, when pfGetArena(data) is
called from the DRAW process it returns NULL ie. it
claims the data is not stored in the shared memory
arena, yet when called from the APP process it correctly
returns the address of the arena.
It appears as though each process is getting its own
copy of the data, and not sharing a single copy in
the shared memory arena.
A modified version of the performer demo code "basic.C"
is shown below which exhibits the problem.
Any ideas?
cheers
steve
--#include <stdlib.h> #include <stdio.h> #include <new> #include <Performer/pf.h> #include <Performer/pf/pfPipe.h> #include <Performer/pf/pfPipeWindow.h> #include <Performer/pf/pfScene.h> #include <Performer/pf/pfLightSource.h> #include <Performer/pf/pfChannel.h> #include <Performer/pfdu.h>
void windowSetup(char *title); void sceneSetup(void); void channelSetup(void); void DrawFunc(pfChannel *chan, void *data);
struct Shared { int shared_int; };
Shared *shared_area; pfuEventStream events; pfScene *scene;
int main(int argc, char *argv[]) { pfInit(); pfMultiprocess( PFMP_FORK_CULL | PFMP_FORK_DRAW ); pfdInitConverter(".flt"); pfConfig();
shared_area = (Shared *)pfCalloc(1, sizeof(Shared), pfGetSharedArena()); shared_area->shared_int = 1;
windowSetup(argv[0]); sceneSetup(); channelSetup();
while ( 1 ) { pfFrame();
fprintf(stderr, "Value in APP: %d\n", shared_area->shared_int);
void *arena = pfGetArena(shared_area); if ( arena ) fprintf(stderr, "APP: shared area allocated from arena: %8p\n", arena); else fprintf(stderr, "APP: shared area allocated from heap\n"); }
return 0; }
void DrawFunc(pfChannel *chan, void *data) { fprintf(stderr, "Value in DRAW: %d\n", shared_area->shared_int);
void *arena = pfGetArena(shared_area); if ( arena ) fprintf(stderr, "DRAW: shared area allocated from arena: %8p\n", arena); else fprintf(stderr, "DRAW: shared area allocated from heap\n");
pfDraw(); }
void windowSetup(char *title) { pfPipe *pipe; pfPipeWindow *win;
pipe = pfGetPipe(0); win = new pfPipeWindow(pipe); win->setName(title); win->setSize(500, 500); win->open(); }
void sceneSetup(void) { pfNode *model; pfLightSource *light;
scene = new pfScene();
light = new pfLightSource(); scene->addChild(light);
pfFilePath("/usr/share/Performer/data"); model = pfdLoadFile("esprit.flt"); scene->addChild(model); }
void channelSetup(void) { pfPipe *pipe; pfChannel *chan; pfCoord view;
pipe = pfGetPipe(0); chan = new pfChannel(pipe); chan->setScene(scene);
view.hpr.set(0.0f, 0.0f, 0.0f); view.xyz.set(0.0f, -7.0f, 0.0f); chan->setView(view.xyz, view.hpr);
chan->setTravFunc(PFTRAV_DRAW, DrawFunc); }
This archive was generated by hypermail 2b29 : Thu Apr 10 2003 - 00:46:32 PDT