?mmap?

Corinna Vinschen cygwin@cygwin.com
Mon Mar 19 07:14:00 GMT 2001


On Mon, Mar 19, 2001 at 03:43:08PM +0200, Claus Wagner wrote:
> the second call returns the same address as the first call has returned.
> 
> There are some cases, which make a multiple mapping of the same piece of a file
> reasonable.
> 
> For example setting different protection attributes for two regions of one file:
> 
> ....
> ptr1 = mmap(fd,...,offset);
> ptr2 = mmap(fd,...,offset);
> ....
> mprotect(ptr1,PROT_READ,PAGE_SIZE);
> mprotect(ptr2,PROT_WRITE|PROT_READ,PAGE_SIZE);
> .....
> 
> 
> Anyway, I don't think, that the semantic of mmap should be like it is right now
> in your implementaion.

Please note that the mmap semantic of Win32 is very different to
the POSIX implementation. There's no way to get an exact match between
them. That's somewhat more difficult if you have a look into the
different implementations between 9x/ME on one hand and NT/W2K on
the other.

> Regards Claus Wagner.
> 
> ps: ... or should I read the POSIX standard :-)

Excerpt from SUSv2
( http://www.opengroup.org/onlinepubs/007908799/xsh/mmap.html ):

=== SNIP ===
... The value of pa is an implementation-dependent function of
the parameter addr and the values of flags, further described
below. ...

... The mapping established by mmap() replaces any previous mappings
for those whole pages containing any part of the address space of
the process starting at pa and continuing for len bytes.

... If MAP_SHARED is specified, write references change the
underlying object. ...
=== SNAP ===

That's all given by the current implementation so I don't see a problem
here. If you're using the MAP_PRIVATE flag, you will not see that
behaviour.

Corinna

-- 
Corinna Vinschen                  Please, send mails regarding Cygwin to
Cygwin Developer                                mailto:cygwin@cygwin.com
Red Hat, Inc.

--
Want to unsubscribe from this list?
Check out: http://cygwin.com/ml/#unsubscribe-simple



More information about the Cygwin mailing list