Re: mmap and munmap question/problem (under iOS, proably no important)
Re: mmap and munmap question/problem (under iOS, proably no important)
- Subject: Re: mmap and munmap question/problem (under iOS, proably no important)
- From: Daniel Vollmer <email@hidden>
- Date: Sun, 05 Feb 2012 13:51:05 +0100
Hi David,
On 4 Feb 2012, at 16:14, David Hoerl wrote:
> I have a huge file with which I use mmap to bring in selected pieces. When done, I then munmap the piece.
>
> However, my code is threaded, and I am getting crashes which I **believe** at this moment to be related to munmap. Specifically, if two threads map pieces in which overlap, the first munmap appears to unmap the area used by the second thread, and boom, down goes my app.
>
> If I'm correct in this assumption, then it occurred to me that if I could chunk my memory such that no two pieces would appear on the same page, the problem would go away. The only other alternative I've thought of is just queuing all munmap calls until such time that all threads finish.
I looked at this a little bit (on 10.7.3 x64_64) just because I was curious:
For each mmap — even when mapping the same region of a file — I get a completely distinct pointer in my address space. If this behaviour is the same on iOS, then munmap'ing any of them shouldn't affect anything else (and I doubt threading plays a role in this as the m*map-routines surely have to take a kernel-lock.
Are you sure that the rest of your code is correct?
Daniel.
_______________________________________________
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