From: Michael V. <mi...@bl...> - 2001-04-02 15:00:59
|
On Sun, 1 Apr 2001, Erik Paulson wrote: > > On Sat, 10 Mar 2001, Erik Paulson wrote: > > > > > Well, if nothing else this post will serve to see if the message archives > > > work :) > > > > It doesn't actually appear that the archives work yet... I think it's ok now. I didn't have archiving enabled on the mailing list, seems you need to explicitly enable it. > But anyway, this is related to your post on the UML list the other day - > how do you implement mmap() under LINE if Win32 requires you to use > 64K chunks? With lots of ugly kludges :) (here's link to that post if anybody wants a little bit of background http://www.geocrawler.com/archives/3/709/2001/3/0/5450072/ ) When MAP_SHARED is used, LINE has no choice but to forward the request to the Cygwin mmap(). I guess it could handle it internally, but LINE would be doing the exact same thing as Cygwin is doing so there is no point. Cygwin uses MapViewOfFileEx() to perform the actual maping. This is the only Win32 API function that will allow processes to share memory. So LINE also suffers from the 64K alignment issue, but LINE tries hard to hide the problem. It really only comes into play when you do a mmap(MAP_SHARED | MAP_FIXED). Most apps seem to just use MAP_SHARED and don't really care where the memory gets placed. UML being one of the exceptions to this. The Win32 API does not explictly state 64K alignment, the actual number is implementation dependent. However all current Win32 implementations use 64K, but maybe WinXP will be better. MAP_PRIVATE is a completely different beast. It is handled completely internally by LINE. The Cygwin mmap() can't be used because Cygwin still uses MapViewOfFileEx() for private mappings. This is problematic because the ELF loader often does mmap(MAP_PRIVATE|MAP_FIXED) at page alignment. This would make it impossible to even load a simple hello world app, so LINE does it's own memory allocation with VirtualAlloc() and friends. But there is a trade-off, the major problem with using VirtualAlloc() is that if you are mapping part of a file into memory. LINE must read the file into memory immediately. There are actually a number of incompatibilities between the LINE mmap() and Linux mmap(). Another notable problem is that Linux lets you mmap() the same region of memory multiple times, possibly changing the mapping type at the same time (MAP_SHARED => MAP_PRIVATE or something). LINE won't let you do that. Mike |