[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
RE: detecting mmap?
From: |
Donn Terry |
Subject: |
RE: detecting mmap? |
Date: |
Fri, 19 Jul 2002 09:55:32 -0700 |
Yes, I meant FIXED... Sorry.
It takes contortions either way: if you map over the top of the heap,
you first have to
be sure there is enough heap to do it. Which means, probabaly,
allocating 2*PAGESIZE
more than you need out of the heap (if you use malloc to get the space)
so that you
can meet the alignment requirements AND not end up with the same
problem. (If the end
of the mapped region happens to be the same as the end of the heap,
which could
happen for some malloc implementations, you could end up with the same
problem.)
addr = mmap(...size, no MAP_FIXED...);
mmap(addr + ROUND_UP(...size...), PAGESIZE, MAP_FIXED...);
doesn't look any worse than that. It doesn't look any worse than
explicit sbrk()
calls, either.
(You do make a good point, however. Maybe we need to consider adding a
"MAP_ALL" flag
to mmap() that says "validly map size, even if it's bigger than the
object" (and zero fill)).
That could be prototyped now, and proposed for the next POSIX if it
works out to be useful.
(Yeah, I know, it doesn't solve the immediate problem, but in the long
run....))
Donn
-----Original Message-----
From: Bruce Korb [mailto:address@hidden
Sent: Friday, July 19, 2002 8:59 AM
To: Donn Terry
Cc: Paul Eggert; address@hidden
Subject: Re: detecting mmap?
Donn Terry wrote:
> I've run across at least a couple of real-world examples where mmap()
> (either without MAP_PRIVATE at all or limited to prior mmap()ed
> addresses) is still quite useful. (In
> fact, the applications run just fine.) I'll have to refresh myself on
> which ones; that
> was some time ago.
Assuming you meant "FIXED", the worst wart I've bumped into is when I
have wanted to mmap a text file that happens to be a multiple of the
page size. strlen() seg faults. It takes some contortions to mmap an
anonymous page after the valid file data. Ick.