Subject: Re: Wine & NetBSD?
To: Christos Zoulas <>
From: Chuck Cranor <>
List: tech-kern
Date: 11/21/2001 21:48:59
On Wed, Nov 21, 2001 at 11:16:12AM -0500, Christos Zoulas wrote:
> On Nov 21, 10:07am, (Chuck Cranor) wrote:
> | the function uses a vfork() ("to freeze all threads of the current process")
> | and then an mincore() to probe the address space.
> | 
> | as an aside: i think that mincore() isn't the right thing to use because
> | it probes for resident pages .. not memory mappings, but it prob. works 
> | most of the time.
> Interesting... I think there should be a way to probe the mapping
> of an address. Do any other OS's specify an API for that?

i can't think of such an API.  on NetBSD you can find it out by
looking at /proc/curproc/map (provided that /proc is mounted) -- but
that's not really an API.

even if there was a "probe the mappings" API, it isn't clear to
me that it would be sufficient for Wine.   it seems to be assuming
a multithreaded environment, but it does not use any locking on
the threads to protect the address space --- that's why they shoved
that vfork() in the solaris "try" mmap function.    instead, it depends
on the fact that linux-ish mmaps atomically tests for mapping and then
establishes the mapping if nothing was there.

if you broke it up into two system calls: "probe for mapping" and then
"do mmap" you'd have a race between the probe and mmap call (unless 
there was some sort of locking).

if we wanted to add the "try fixed mapping" semantic to the API,
it seems like the way to do it would be with a new MAP_* flag
(e.g. MAP_TRYFIXED).   if nothing else it seems like something you'd
want internally for linux emulation?