Very Large Framestores on Sun: addr

lee at srs.UUCP lee at srs.UUCP
Thu Mar 12 02:18:20 AEST 1987


> 
> The  problem  is  that  the valloc  actually allocates  the amount of
> memory you are requesting.  If you don't have enough swap space free,
> the valloc fails.  Thus not allowing you to get  a chance  to map the
> physical to virtual address.  
> 
> 				Bob Berger 
> 
> Datacube Inc. Systems / Software Group	4 Dearborn Rd. Peabody, Ma 01960
> VOICE:	617-535-6644;	FAX: (617) 535-5643;  TWX: (710) 347-0125

This may be of general interest, so I am posting it to the net.

Essentially all that valloc() does is this:

char *
valloc(size)
unsigned size;
{
    int pagesize;
    char *p = malloc(size + (pagesize = getpagesize()));

    while ((int)(p) % pagesize != 0)
	p++;

    return(p);
}

This means that it malloc's page aligned areas of memory, so that a subsequent
call to mmap() can remap these pages to different physical addresses.  Since
malloc() calles 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.



More information about the Comp.unix.wizards mailing list