
Guido van Rossum writes:
Hmm... I don't know of any way to use mmap() on non-file things, either; there are odd special cases, like using MAP_ANONYMOUS on /dev/zero to allocate memory, but that's still using a file. On the other hand, there may be some special case where you need to do that. We could add a fileno() method to get the file descriptor, but I don't know if that's useful to Windows. (Is Sam Rushing, the original author of the Win32 mmapfile, on this list?) What do we do about the tagname, which is a Win32 argument that has no Unix counterpart -- I'm not even sure what its function is. -- A.M. Kuchling http://starship.python.net/crew/amk/ I had it in me to be the Pierce Brosnan of my generation. -- Vincent Me's past career plans in EGYPT #1

Andrew M. Kuchling wrote:
On Windows, a mmap is always backed by disk (swap space), but is not necessarily associated with a (user-land) file. The tagname is like the "name" associated with a semaphore; two processes opening the same tagname get shared memory. Fileno (in the c runtime sense) would be useless on Windows. As with all Win32 resources, there's a "handle", which is analagous. But different enough, it seems to me, to confound any attempts at a common API. Another fundamental difference (IIRC) is that Windows mmap's can be resized on the fly. - Gordon

but that's not always the case -- OSF/1 supports truly anonymous mappings, for example. in fact, it bombs if you use ANONYMOUS with a file handle: $ man mmap ... If MAP_ANONYMOUS is set in the flags parameter: + A new memory region is created and initialized to all zeros. This memory region can be shared only with descendents of the current pro- cess. + If the filedes parameter is not -1, the mmap() function fails. ... (btw, doing anonymous maps isn't exactly an odd special case under this operating system; it's the only memory- allocation mechanism provided by the kernel...) </F>

Andrew M. Kuchling wrote:
On Windows, a mmap is always backed by disk (swap space), but is not necessarily associated with a (user-land) file. The tagname is like the "name" associated with a semaphore; two processes opening the same tagname get shared memory. Fileno (in the c runtime sense) would be useless on Windows. As with all Win32 resources, there's a "handle", which is analagous. But different enough, it seems to me, to confound any attempts at a common API. Another fundamental difference (IIRC) is that Windows mmap's can be resized on the fly. - Gordon

but that's not always the case -- OSF/1 supports truly anonymous mappings, for example. in fact, it bombs if you use ANONYMOUS with a file handle: $ man mmap ... If MAP_ANONYMOUS is set in the flags parameter: + A new memory region is created and initialized to all zeros. This memory region can be shared only with descendents of the current pro- cess. + If the filedes parameter is not -1, the mmap() function fails. ... (btw, doing anonymous maps isn't exactly an odd special case under this operating system; it's the only memory- allocation mechanism provided by the kernel...) </F>
participants (3)
-
Andrew M. Kuchling
-
Fredrik Lundh
-
Gordon McMillan