shmat() with fixed address
Hi,
I'm using Ubuntu 10.04 on a 64bit machine. In my shmat() call, I want to assign fixed memory address to shmaddr variable. I have no idea which address value to give. Some where in the net I read we can make use of sysproc info to know the user space addresses, but could not figure out how to get that, please help on this. void *shmat(int shmid, const void *shmaddr, int shmflg); Note: ----- the reason I want to use fixed address is to build linked list on the shmget() returned memory and my other process will map into fixed address and access the linked list. |
Hi there,
You likely do not need to know where the memory is going to be mapped: 1. Use ftok() to construct a key for the shared memory . 2a. In one process use shmget() with IPC_CREATE to create a sufficiently large shared memory segment. 2b. In your other processes use shmget() without IPC_CREATE. 3. In all the processes you then call shmat() with the id from shmget() and a NULL shmaddr. In each process shmat() returns where the memory has been mapped, that's the start of the shared segment. Cheers, Steve |
All times are GMT -5. The time now is 11:36 AM. |