• 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: Using mmap to extend an existing mapping?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Using mmap to extend an existing mapping?


  • Subject: Re: Using mmap to extend an existing mapping?
  • From: Jens Alfke <email@hidden>
  • Date: Thu, 8 Oct 2009 09:08:19 -0700


On Oct 7, 2009, at 11:12 AM, Terry Lambert wrote:

Typically you are expected to keep your mapped regions away from stack and heap allocations, which means either limiting yourself to a fraction of the address space and using a generally unused region, or by establishing your mapping followed immediately by an adjacent mapping of zero-fill pages that you can later choose to map over top of

Thanks! This sounds like it requires knowing ahead of time where to put the mappings, and specifying fixed addresses. But how do you know? Hardcoding an address makes assumptions about how the OS lays out process address spaces (and this is code I'd like to make cross- platform), and runs the risk of colliding with other libraries that are making the same assumptions and trying to use the same addresses. But I don't know of any API that would let me figure this out dynamically, i.e. by iterating over the already-allocated address ranges.


Let's say my file is currently 100k but I want to allow for growth up to 10MB. If I call mmap with a range of (0,10MB) what happens? Does the kernel only allocate 100k, or do I get a 10MB region? If the latter, then if I append to the file does the new data appear in the region (assuming I used MAP_SHARED)? That would get me the behavior I want...

(Apologies if these are obvious newbie questions. Feel free to point me to in-depth coverage of mmap; I've done some googling but not exhaustively.)

—Jens _______________________________________________
Do not post admin requests to the list. They will be ignored.
Darwin-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


  • Follow-Ups:
    • Re: Using mmap to extend an existing mapping?
      • From: Terry Lambert <email@hidden>
References: 
 >Using mmap to extend an existing mapping? (From: Jens Alfke <email@hidden>)
 >Re: Using mmap to extend an existing mapping? (From: Terry Lambert <email@hidden>)

  • Prev by Date: Re: getting library information wrt address.
  • Next by Date: Re: Using mmap to extend an existing mapping?
  • Previous by thread: Re: Using mmap to extend an existing mapping?
  • Next by thread: Re: Using mmap to extend an existing mapping?
  • Index(es):
    • Date
    • Thread