Re: Using mmap to extend an existing mapping?
site_archiver@lists.apple.com Delivered-To: darwin-dev@lists.apple.com On Oct 7, 2009, at 11:12 AM, Terry Lambert wrote: —Jens _______________________________________________ Do not post admin requests to the list. They will be ignored. Darwin-dev mailing list (Darwin-dev@lists.apple.com) Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/darwin-dev/site_archiver%40lists.appl... 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.) This email sent to site_archiver@lists.apple.com
participants (1)
-
Jens Alfke