yes you can do shared memory (you have to do the syncronization yourself !)
first process allocates the memory using shget
this would create a new segment available to same user id or provide access by another process
int segment_id = shmget(shm_key, getpagesize(), IPC_CREAT | S_IRUSER | S_IWUSER);
then you attach the shared segment to a certain address space using shmat() with segment_id
returned from shmget like
char *shared_mem = (char*) shmat (segment_id, (void*) 0x5000000, 0);
detatch is
shmdt(shared_mem);
dealocate is
shmctl (segment_id, IPC_RMID, 0);
you can get info like
struct shmid_ds shmbuffer;
shmctl(segment_id, IPC_STAT, &shmbuffer);
int segment_size = shmbuffer.shm_segsz;
the first value passed to shget is the key other processes can use as an identifier to gain acess
if you need to garantee a new segment use the macro IPC_PRIVATE for the key
|