mmap (was What new system calls do you want in BSD?)

Kemp at dockmaster.ncsc.mil Kemp at dockmaster.ncsc.mil
Wed Feb 7 10:17:00 AEST 1990


Doug Gwyn writes:
 > Larry McVoy writes:
 >> Anyway, it's tough to do this otherwise.  Protection is implemented
 >> via the MMU.  I can't think of any other reasonable (performance)
 >> way to do it.
 >
 > I appreciate that, but you do see the point, I hope.
 > A user-mode application has no reasonable handle on the notion of
 > "page alignment"; . . .
 >
 > . . . lacking a system-provided function like
 >  void *PageAlign( void *base_pointer, size_t extent );
 >   . . . there is no way I can see to use mmap() portably even among
 > systems on which it exists.

I fail to understand why mmap(2) can't be used portably.

 caddr_t mmap( caddr_t addr, int len, int prot, int flags,
             int fd, off_t off );

 " mmap() establishes a mapping between the process's address space
 at an address paddr for len bytes to the memory object represented
 by fd at off for len bytes.  The value of paddr is an implementation
 dependent function of the parameter addr and the values of flags,
 . . .  A successful mmap() returns paddr as its result."

In other words, a user mode application should have *no* handle at all
on the notion of "page alignment".  It should just regard the value
returned by mmap as a pointer to memory that is valid for the particular
hardware on which it is running.  In fact, page alignment alone may not
be a sufficient condition for validity.

What's non-portable about that?

   Dave Kemp <Kemp at dockmaster.ncsc.mil>



More information about the Comp.unix.wizards mailing list