valloc() & mmap() on SUN's

jwf at munsell.UUCP jwf at munsell.UUCP
Fri Mar 13 07:30:20 AEST 1987


Concerning valloc() and mmap() on a SUN, lee at srs.UUCP (Lee Hasiuk) writes:

> Since malloc() calls sbrk() and the kernel calls swapexpand() in the code
> which handles sbrk(), Sun claims that you need the space on your swap
> device which is as big as the area that you are going to map.  HOWEVER,
> the code for mmap ACTUALLY FREES THE SWAP AREA of the pages which get
> mapped, so that if you map your frame buffer a megabyte at a time, for
> example, you would only need one meg of free swap area to work with.  You
> shouldn't use valloc to do this, however, if you want the areas to be
> contiguous in the virtual address space of your process.  Instead, you
> should call sbrk() yourself.

Unfortunately, SUN 3.0 only supports *one* hole in the user virtual
space, i.e., one range of pages that do not have corresponding swap
space.  So only the first mmap() frees up swap space, subsequent ones do
the requested mapping but leave the swap space allocated.  This is ugly
and not very useful.

The hole (if any) is kept track of in the u. structure:

	struct	hole {		  /* a data space hole (no swap space) */
		int	uh_first; /* first data page in hole */
		int	uh_last;  /* last data page in hole */
	} u_hole;

Note that this is a single structure, not a linked list.  So there is no
mechanism to record a number of holes in the virtual space.
-----
{harvard!adelie,{decvax,allegra,talcott}!encore}!munsell!jwf

Jim Franklin, Eikonix Corp., 23 Crosby Drive, Bedford, MA 01730
Phone: (617) 275-5070 x415



More information about the Comp.unix.wizards mailing list