• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Shared Memory and Distributed Objects
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Shared Memory and Distributed Objects


  • Subject: Re: Shared Memory and Distributed Objects
  • From: Mike Davis <email@hidden>
  • Date: Sun, 16 Feb 2003 22:46:22 +0000

Just be aware that the p-thread mutexes do not work between processes, although the correct defines are there. This messes up one of the Stephen's examples for shared memory.

The same Stephen's book has a load about doing shared memory. It's the one that covers p-threads. I'm using a mixture of the APIs in my code as I have to build for both MacOS X and Linux (*sigh*). The Mac has both of the APIs but I have to emulate some of the POSIX stuff on Linux (using Stephen's example code - which is not thread safe) as the Linux implementation does not work (according to the man pages!). Basically, I create a different kind of mutex to lock the shared memory.

As for DO, it doesn't really fit into this model (directly). If you're using DO, one could argue that processes using the shared memory shouldn't be. Of course, that's not realistic of one of the processes is POSIX based. The downside of DO for my code is that it requires a RunLoop. I don't have such a luxury as there's neither a run loop or Objective-C DO (GNU on Linux).

Slightly off topic but I emulated the Windows SendEvent() WIN32 call (I also support Windows too) using a client/server model. It's just a subject/observer pattern and compiles on UNIX based/like clients. The interface is a lot like the NSDistributedNotification one, except in C++. The relevant information is that the first process looking for the notification server starts a daemon (man daemon) sub-process (man fork) so what might appear as shared memory behaviour (SendEvent()) is nothing of the sort. Not very efficient but it works. I couldn't think how to do, effectively, a broadcast any other way on the localhost which is suitable for generic OSs.

Mike.

On Sunday, February 16, 2003, at 10:00 PM, email@hidden wrote:

From what you've described, I'd suggest delving a bit deeper into
mmap(). This deceptively simple system call opens up access to the VM
and swap machinery of the kernel. mmap() is the API of choice for
sharing memory between processes. For example, it's how the operating
system manages shared libraries. And because it is such a thin veneer
over the kernel VM system, it can be counted on to behave reliably and
predictably with no special tweaking or tuning.
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.

  • Prev by Date: Re: Get path to user preference folder, problem solved!
  • Next by Date: Re: NSString is cutting off characters
  • Previous by thread: Re: Shared Memory and Distributed Objects
  • Next by thread: Re: Shared Memory and Distributed Objects
  • Index(es):
    • Date
    • Thread