• 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: Kaelin Colclasure <email@hidden>
  • Date: Sun, 16 Feb 2003 17:29:51 -0800

The simplest way to use mmap() is to have a file on disk the size of the memory region you want shared. Make this a shared mapping between two (or more) processes, and they will all be looking at the same physical pages of RAM (albeit most likely with different virtual addresses). And no, updates will not need to be synched to disk to be shared. In general, unless you explicitly ask for a sync, it will happen only once the file is closed by all processes or in the event that the VM system needs to reclaim the RAM for something else.

Think of it as the file on disk acting as a dedicated swap space for the shared memory -- because that is precisely how it behaves. And as an added bonus, you can effectively pre-initialize the shared memory simply by writing something into the mapped file. If you truly have no use for the file beyond the lifetime of the processes in question, they can simply create a temporary file and use that.

-- Kaelin

On Sunday, February 16, 2003, at 12:10 PM, Dan Bernstein wrote:


On Sunday, February 16, 2003, at 10:00 PM, Kaelin Colclasure wrote:

mmap() is not used with System V shared memory objects (AFAIK). The fd mmap() wants is a normal filesystem file handle.
[snip]
From what you've described, I'd suggest delving a bit deeper into mmap().

Thanks. But right now I'm lost. In order to be able to map the same memory from two processes, what should I do? Specifying a shared memory object doesn't work (so where *do* they work in Darwin?), so I guess I should give mmap() a normal filesystem file handle. But then isn't stuff going to get written to disk by sync() every now and then, even if I have enough real memory to hold it in, at least unnless I...
tweak various kernel parameters to achieve usable results.)
?

Thanks,
-- Dan
_______________________________________________
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.

  • Follow-Ups:
    • Re: Shared Memory and Distributed Objects
      • From: Dan Bernstein <cocoa-dev%email@hidden>
References: 
 >Re: Shared Memory and Distributed Objects (From: Dan Bernstein <cocoa-dev%email@hidden>)

  • Prev by Date: mysterious NSOutlineView crashing
  • Next by Date: (another) IB resizing question
  • Previous by thread: Re: Shared Memory and Distributed Objects
  • Next by thread: Re: Shared Memory and Distributed Objects
  • Index(es):
    • Date
    • Thread