Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!sdd.hp.com!spool.mu.edu!samsung!noose.ecn.purdue.edu!orchestra.ecn.purdue.edu!songer From: songer@orchestra.ecn.purdue.edu (Christopher M Songer) Newsgroups: comp.sys.next Subject: Re: shared memory on NeXT Message-ID: <1991Mar1.134610.22000@noose.ecn.purdue.edu> Date: 1 Mar 91 13:46:10 GMT References: <12159@pt.cs.cmu.edu> Sender: root@noose.ecn.purdue.edu (ECN System Management) Organization: Purdue University Engineering Computer Network Lines: 33 Christopher Maeda writes: >Why not just rewrite your code to use ports and messages? A mach >message (within a single host) is implemented as a piece of shared >memory anyway. You don't need to mess with semaphores since the OS >does the synchronization for you when it delivers the message. You >also get network transparency for free. > >I imagine the reason the vm code doesn't let arbitrary processes share >pieces of memory is that you are supposed to use ports and messages >for this sort of thing. Well, I guess my first answer is laziness. When a program really uses the shared memory, it tends to permeate the program. It is not something which is localized to a few spots. Sure there are only a couple of shm* calls, but the pointers that get returned can be used all over. So a program which REALLY uses shared memory is a pain to port. I'd like to do it once and for all, all up front. I want to make a library and a set headers that I can use to make sysV programs run with NO extra work. The CMU version of mach has a way to do shared memory cleanly. What you do is get a memory object and register yourself as the pager for that object. All of the programs sharing the memory use the vm_map command to map that memory object into their address space and then as the pager, you get called to handle any page faults. This scheme could be hidden behind the shm* calls. (All this is from a couple of tech documents at the CMU ftp server wb1.cs.cmu.edu) So while you are right, arbitrary processes are not supposed to shared memory directly, there is still a clean way to implement it. -Chris