MEMGET(K) UNIX System V MEMGET(K)
Name
memget - allocates contiguous memory at initialization
Syntax
int
memget(pages)
int pages;
Description
The memget routine is used to obtain permanent, contiguous
memory for the driver at initialization time. It is
intended for memory that the driver will always have and
use. Its argument is the size of memory in pages. Use the
macro btoc(K) to calculate the number of pages from the
number of bytes required. memget's return value is also in
pages, so the ctob(K) macro must be used to translate the
return value of memget into a kernel virtual address. Both
ctob and btoc are defined in the file
/usr/include/sys/sysmacros.h.
Parameters
pages is the number of pages to allocate.
Warning
This routine is intended for use in a driver's
initialization routine for use before any user processes
have been run. Calling memget in other routines can result
in a caller sleeping forever. If physically contiguous
memory is not immediately available, memget goes to sleep
with periodic checks, but never rearranges pages to obtain
the memory. Thus if the memory is not available during a
check, memget returns to sleep, and may never find available
memory.
Return Value
The page frame number of the first frame of memory allocated
is returned.
Example
To obtain a permanent 4K buffer for a driver, use the
following code statement:
char *always;
always = (char *) ctob( memget( btoc( 0x1000 ) ) );
(printed 7/6/89)