Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!


Using Shared Memory

andy101andy101 Member Posts: 15
Can anyone see anything wrong with this scheme - its two separate programs using shared memory.

[code]//COMMON DATA - Each program has
typedef struct
double timeStamp; // Time stamp (seconds)
double data1;
double data2;
double data3;
double data4;

#define SHMSZ 2048
key = 8192; // key
int shmid; // Shared memory ID
DataStruct shareData;
void *shm; // shared memory pointer

shmid = shmget(key, SHMSZ, 0666 | IPC_CREAT);
shm = shmat(shmid, (void*)NULL, 0));

//THE WRITER - write new data into shared memory
dataLength = sizeof(shareData);
memcpy(shm, &shareData, dataLength);

//THE READER - read out the data from shared memory into the readers data structure
dataLength = sizeof(shareData);
memcpy(&shareData, shm, dataLength);[/code]
Are they a way to look at the contents of this shared memory. I can see it via the ipcs -m command but would like to look at a Hex dump if possible.

Many thanks,

Sign In or Register to comment.