[comp.os.mach] shared memory in Mach?

briand@rfengr.com (Brian Dear) (02/21/91)

Forgive me if this is a stupid question.  Here goes:

My first exposure to Mach is via the NeXT machine.  One thing I was
disappointed to discover was that with NeXT's OS, there is no support
for "shared memory" operations such as System V's shmget(), shmat(),
and shmdt().
 
Does anyone know if a simple way to implement the equivalent of
AT&T System V shared memory in a Mach-style environment?  Mach is
supposed to be quite powerful with regard to interprocess communication.
What's the *easiest* way to have two unrelated processes share a chunk
of memory by attaching it to their address space and reading/writing it?
Assume the processes are not children of each other.  I want one
process to be able to communicate with a completely unrelated process
using the fastest method possible (which I assume would be some 
direct memory operation).

Any suggestions welcome.  If you would like to respond via e-mail,
please reply to: brian@coconut.com

Thanks!

Brian Dear                  brian@coconut.com          Coconut Computing, Inc.

zwilling@caseus.cs.wisc.edu (Mike Zwilling) (02/22/91)

In article <1991Feb21.072121.24132@rfengr.com> brian@coconut.com writes:
>
>Forgive me if this is a stupid question.  Here goes:
>
>Does anyone know if a simple way to implement the equivalent of
>AT&T System V shared memory in a Mach-style environment?  Mach is
>supposed to be quite powerful with regard to interprocess communication.
>What's the *easiest* way to have two unrelated processes share a chunk
>of memory by attaching it to their address space and reading/writing it?
>Assume the processes are not children of each other.  I want one
>process to be able to communicate with a completely unrelated process
>using the fastest method possible (which I assume would be some 
>direct memory operation).

Two unrelated processes (tasks) in Mach can share (read/write)
memory in Mach using a memory_object.  Any tasks which map
the memory object into their virtual address space, will share
memory with other tasks mapping the same object.  

The intialization and paging for a memory object must be managed by a 
server (external pager).  An external pager is represented by a 
port which responds to RPC's from the kernel.  Therefore, 
it can be implemented as a separate task or simply as a thread in one 
of the tasks which is sharing the memory.  A good example of such a 
server is the netmemory server which is supplied in the Mach 2.5 
release.  This server supports r/w sharing of memory for multiple 
memory_objects, even across a network.

Mike
-- 
Mike Zwilling   University of Wisconsin -- Madison              
Computer Sciences Dept.
1210 W. Dayton St.
Madison, WI  53706    email: zwilling@cs.wisc.edu   ph# (608) 263-4076

webb@ibmpa.awdpa.ibm.com (Bill Webb) (02/22/91)

In article <1991Feb21.072121.24132@rfengr.com>, briand@rfengr.com (Brian Dear) writes:
|> 
|> Forgive me if this is a stupid question.  Here goes:
|> 
|> My first exposure to Mach is via the NeXT machine.  One thing I was
|> disappointed to discover was that with NeXT's OS, there is no support
|> for "shared memory" operations such as System V's shmget(), shmat(),
|> and shmdt().
|>  
|> Does anyone know if a simple way to implement the equivalent of
|> AT&T System V shared memory in a Mach-style environment?  ...
|> ...
|> Brian Dear                  brian@coconut.com          Coconut Computing, Inc.

The simplest way of getting this would be to get OSF/1 which is based on
Mach and has the shm* facilities.

----------------------------------------------------------------
The above views are my own, not necessarily those of my employer.
Bill Webb (IBM AWD Palo Alto, Ca.), (415) 855-4457.
UUCP: ...!uunet!ibmsupt!webb INTERNET: webb@ibminet.awdpa.ibm.com