Subject: [Dev] Re: [TriLUG] anybody use pointers and shared memory?

From: Tanner Lovelace <[email-masked]>
Date: 15 May 2002 15:49:01 -0400

On Wed, 2002-05-15 at 15:30, John F Davis wrote:
> Hello
> 
> I know how to use shared memory between processes via shmget and shmat, but
> I'm not an expert on their use.  (I've used it for simple flat structures.)
> Anybody have any experience using them with something similar to malloc'd
> pointers?  For instance, if I want to dynamically allocate data that is
> shared, do I have to use shmget/shmat in lieu of malloc?
> 
> Yes, I realize each process has their own heap so malloced pointers shared
> between process's are meaningless, but is their some simple technique for
> dynamic  shared memory?
> 
> I realize I'm not very clear on this.  Its easier to describe the problem
> more concisely with code, but I don't have any code written at this point
> because I am just thinking out loud.
> JD

Hi John,

Could you explain a little more about what you're doing?  If you're
trying to share memory between two processes that were created from
the same original process using fork, you should probably look
at the mm library (http://www.engelschall.com/sw/mm/).  If you're
trying to share between two completely separate processes, however,
then mm won't help you.

It sounds like what you need is basically SGI Arenas, which, as
far as I know, aren't available under linux.  (Actually, the 
SGI performer team did a port of it to linux but last I heard
it wasn't :-( open source.)  I was looking for something like
this a while back for completely disparate processes and didn't
have any luck finding anything.  If you do come up with something,
I'd be interested in hearing about it.

BTW, I've cc'd the dev list for this.  This sounds like it is
more properly a question for that list.  (Although, if anyone 
on the main list wants to answer it, please don't let me discourage
you.)

Tanner
-- 
Tanner Lovelace | [email-masked] | http://wtl.wayfarer.org/
--*--*--*--*--*--*--*--*--*--*--*--*--*--*--*--*--*--*--*--*--*--*--
GPG Fingerprint = A66C 8660 924F 5F8C 71DA  BDD0 CE09 4F8E DE76 39D4
GPG Key can be found at http://wtl.wayfarer.org/lovelace.gpg.asc
--*--*--*--*--*--*--*--*--*--*--*--*--*--*--*--*--*--*--*--*--*--*--
Have we sent the "Don't shoot, we're pathetic" transmission yet? 
                                Commander John Crichton (Farscape)

---

From: H Brett Bolen <[email-masked]>
Date: Wed, 15 May 2002 16:44:53 -0400

> shared, do I have to use shmget/shmat in lieu of malloc?

Hey John,

There is a very simple wrapper class, SharedArray,  here:

  http://www.pressenter.com/~3nelsons/joecode/

it's implemented in the header file, and is easy to use.  as long as
the destructors are called, everything is cleaned up.

use is as simple as

   typedef struct {
     ...
   } MyStruct;

   MyStruct *MyStructArray = new SharedArray< MyStruct> ( "Name", 100);

   MyStructArray[1] = ...

   delete MyStructArray;

may not be exact, but close.

b\375

ps:  I'm forwarding this to [email-masked]

---

From: H Brett Bolen <[email-masked]>
Date: Sat, 01 Jun 2002 13:17:16 -0400

Serendipity strikes again.

I was playing with info pages using kde, and
I found mmalloc.

This looks like what you are asking for, let me
know how it works out.

b\375

H Brett Bolen wrote:7
> _______________________________________________
> Dev mailing list
> [email-masked]
> http://www.trilug.org/mailman/listinfo/dev
>