Xref: utzoo comp.unix.questions:24974 comp.unix.wizards:23604 Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!uunet!virtech!cpcahil From: cpcahil@virtech.uucp (Conor P. Cahill) Newsgroups: comp.unix.questions,comp.unix.wizards Subject: Re: Are pointers in a shared memory segment valid for a different process? Keywords: shared memory, pointers, IPC Message-ID: <1990Aug24.115009.24808@virtech.uucp> Date: 24 Aug 90 11:50:09 GMT References: <838@qusunc.queensu.CA> Reply-To: cpcahil@virtech.UUCP (Conor P. Cahill) Organization: Virtual Technologies Inc., Sterling VA Lines: 35 In article <838@qusunc.queensu.CA> kelley@qucis.queensu.CA (Todd Kelley) writes: > > [Question of using pointers to shared memory segments between two > processes deleted] > The easiest way to do this is to ensure that both processes attach the segment at the same address. In that case, any pointers within the segment will be the same for both processes. The following algorithm could be used: creat a new segment attach at default address calculate extra space needed and re-attach the segment far enough away from your data segment so that you wont run out of malloc space save the address that it was attached at in the first portion of the shared memory segment. For other processes: get segment id attach segment at default address get correct attachment address (from the shared memory segment itself) detach & re-attach at the correct address. The only thing you need to ensure is that when you are leaving enough room between the shared memory segment and your program's standard data segment you must ensure that the resultant address is far enough down for any programs that are going to use this shared memory segment. -- Conor P. Cahill (703)430-9247 Virtual Technologies, Inc., uunet!virtech!cpcahil 46030 Manekin Plaza, Suite 160 Sterling, VA 22170