Subject: Re: POSIX shm_open() vs. mmap(MAP_ANON|MAP_SHARED)....
To: Greywolf <greywolf@starwolf.com>
From: Greg A. Woods <woods@weird.com>
List: tech-kern
Date: 07/10/2003 12:37:59
[ On Wednesday, July 9, 2003 at 13:00:03 (-0700), Greywolf wrote: ]
> Subject: Re: POSIX shm_open() vs. mmap(MAP_ANON|MAP_SHARED)....
>
> Wow, a (vno_t *) NULL was supposed to allow one to create pre-cleared
> pages in memory?

Apparently.  There is only one anonymous object in the system -- why
would you need a "fake" pathname to represent it?  (there's no backing
store in that kind of device file :-)

> I have a question regarding mmap()ing /dev/zero:
> 
>     Purportedly this was used by crt0.o and/or ld.so to create blank spots
>     into which to load the dynamic libraries.  Surely the same thing could
>     have been accomplished with *alloc() and a clear routine,

That would be _very_ expensive in terms of VM for every process since
every page would fault and copy-on-write every time!

>     or
>     mmap() could just pre-zero whatever pages it maps.

Indeed mmap(MAP_ANON) memory is zero-filled (and must be else the
garbage it revealed may violate someones privacy because that garbage
would very likely have come from some other process)

-- 
								Greg A. Woods

+1 416 218-0098;            <g.a.woods@ieee.org>;           <woods@robohack.ca>
Planix, Inc. <woods@planix.com>; VE3TCP; Secrets of the Weird <woods@weird.com>