Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!utgpu!water!watnot!watmath!clyde!rutgers!brl-adm!adm!sfbc!jab@lll-crg.arpa From: jab@lll-crg.arpa Newsgroups: comp.unix.wizards Subject: Shared memory Message-ID: <5701@brl-adm.ARPA> Date: Wed, 25-Mar-87 08:29:29 EST Article-I.D.: brl-adm.5701 Posted: Wed Mar 25 08:29:29 1987 Date-Received: Fri, 27-Mar-87 01:22:18 EST Sender: news@brl-adm.ARPA Lines: 35 > From: Andrew Siegel > Subject: Question about Sys V shared memory > Date: 23 Mar 87 22:28:19 GMT > To: unix-wizards@brl-sem.arpa > > 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. > Great, but unless the SHM segment is attached to the same virtual address in each process, you can't use pointers to describe the free addresses, since they'll be at different virtual addresses in each process. Choices: 1) Store the info on what's free as "byte offset into SHM segment". Then if the SHM segment lives at different places, the addresses each process use would be relative to the beginning of the SHM segment, and each process would know where *THAT* was. 2) Always locate the SHM segment in the same virtual address for all processes, period. The first choice is a lot of things, including more portable and less cumbersome. Unfortunately, it takes more CPU operations to evaluate *(base + offset) than if you know the real address itself. You can see the problems with the second approach. Jeff Bowles Summit, NJ