Xref: utzoo comp.unix.questions:24944 comp.unix.wizards:23580 Path: utzoo!utgpu!news-server.csri.toronto.edu!qucis!kelley From: kelley@qucis.queensu.CA (Todd Kelley) Newsgroups: comp.unix.questions,comp.unix.wizards Subject: Are pointers in a shared memory segment valid for a different process? Keywords: shared memory, pointers, IPC Message-ID: <838@qusunc.queensu.CA> Date: 22 Aug 90 20:17:00 GMT Organization: Queen's University, Kingston, Ontario, Canada Lines: 30 This question is closely related to my previous question about IPC using shared memory (comp.unix.questions). Suppose that process A and process B both have one particular shared memory segment attached to their respective address spaces with shmat(). Now suppose that process A puts an array of strings into the shared memory segment, such that each string resides in the shared memory segment, but they do not occupy a contiguous piece of memory. That array will be meaningless to process B, because the (char *) pointers in the array point into A's address space, and not B's address space. If the base of the shared memory segment is at AAA0 in A's address space, and at BBB0 in B's address space (for example), in order for B to access the strings in the array, B would need to add (AAA0-BBB0) to each of the pointers in the array to make them point at the strings in B's address space. Is this wrong? If not, is there an accepted way to map addresses back and forth between address spaces? For instance, should each string's offset from the base of the segment be stored in the array, rather than the actual pointer? If this *is* wrong, please let me know. Respond by email, and if there seems to be enough interest in this question, I'll post a summary. -- Todd Kelley (kelley@qucis.queensu.ca)