Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!utgpu!water!watnot!watmath!clyde!rutgers!lll-lcc!csustan!csun!aeusesef From: aeusesef@csun.UUCP Newsgroups: comp.unix.wizards Subject: Re: Question about Sys V shared memory Message-ID: <591@csun.UUCP> Date: Wed, 25-Mar-87 11:25:43 EST Article-I.D.: csun.591 Posted: Wed Mar 25 11:25:43 1987 Date-Received: Sat, 28-Mar-87 00:40:38 EST References: <314@nbc1.UUCP> Reply-To: aeusesef@csun.UUCP (Sean Eric Fagan) Followup-To: aeusesef@csun.UUCP Organization: California State University, Northridge Lines: 52 Keywords: Shared Memory, System V In message <314@nbc1.UUCP>, Andrew Siegel writes: >The situation: > >I have a large shared memory segment. I would like to be able to >have a dynamic data structure within that segment, i.e. set aside >some memory within the shm segment for allocation, and have one >or more pointers within the shm segment pointing into this memory >pool. > >The question: > >If process A attaches the shm segment and assigns an address within >the segment's memory pool to one of these pointers, will this >address have any meaning to other processes that attach the >segment? > >My guess: > >Theoretically, no. Practically, I would guess it depends on how >segmentation is done within the host machine. (We have a VAX >running ULTRIX.) > >Any help would be appreciated. Thanks. >-- >Andrew Siegel, N2CN NBC Computer Imaging, New York, NY >philabs!nbc1!andy (212)664-5776 No, but what you can do is use offsets (if you want to just use one shared memory segment), or, even closer (but this may not be what you want) to an equivalent to calloc, get a new segment, and put the segment ID into some reserved location within the original segment (which, I suppose you could re-design just for that purpose). Unfortuneatly, what I think you want to do is something like this: char a[SIZE]; shmat(id,a,0); ptr=&a[some_value_greater_than_0_and_less_than_SIZE]; /*COBOL!*/ and then expect ptr to be the same in all processes. Well, for that, as long as you do not store ptr in some memory location, it will work. However, if you do need to store ptr, you may be able to use a[x]=ptr-a; /*In C, should work*/ I do hope that this helps. ----- Sean Eric Fagan ------\ Computer Center litvax \ Cal State University, Northridge rdlvax \ 18111 Nordhoff St. psivax --> !csun!aeusesef Northridge, CA 91330 hplabs / AGTLSEF@CALSTATE.BITNET ihnp4 / ------/ "I drank what?!" -- Socrates | My opinions *are* facts.