Messages in this thread | | | Date | Fri, 18 Feb 2000 15:40:09 -0800 (PST) | From | (Scott Lurndal) | Subject | Re: shmat on non-NULL address? |
| |
In article <88i3db$6ou1r@fido.engr.sgi.com>, you write: |> According to the man page for shmat, supplying a non-NULL shmaddr |> (with or without asserting SHM_RND) should attach a shared memory |> segment to the address. However, the shmat call always fails unless |> supplied with a NULL shmaddr. I quickly perused the sys_shmat function |> in linux/ipc/shm.c (RedHat 6.1, kernel 2.2.5) and could not tell if |> non-NULL behavior is even implemented. Would someone who is more |> knowledgeable about shared memory than I tell me if it is possible to |> attach an existing address to shared memory? Thanks. |> |> Mark
To successfully attach to a particular address the following constraints must hold:
1) The address is congruent to zero modulo SHMLBA (unless SHM_RND flag is provided).
1) The address is not contained within the bounds of the process stack and stack growth area
3) The address must not be already mapped by an existing mapping (e.g. existing shm segment, mmap'ed region, program text/data/bss, shared object text/data, etc). (unless SHM_REMAP, a non-standard flag, is provided).
It is generally not portable to map shared memory segments to a particular virtual address, certainly not between flavors of unix, and potentially even between revisions of the linux kernel. Better to let the kernel provide the address and use base-relative offset addressing within the shared memory segment.
Oracle, for instance, does attach its SGA (shared global area) to a fixed virtual address (0x50000000 under linux, IIRC).
scott
- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.rutgers.edu Please read the FAQ at http://www.tux.org/lkml/
| |