VMSPACE(9) 386BSD Kernel Programmer's Manual VMSPACE(9)
NAME
vmspace - virtual memory program interface functions
SYNOPSIS
#include "vm.h"
#include "vmspace.h"
struct vmspace *
vmspacefork(struct vmspace *, struct proc *)
void
vmspacefree(struct vmspace *)
int
vmspaceallocate(struct vmspace *vs, vm_offset_t *addr, vm_size_t size,
int findspace)
void
vmspacedelete(struct vmspace *vs, caddr_t va, unsigned sz)
int
vmspacemmap(struct vmspace *vs, vm_offset_t *addr, vm_size_t size,
vm_prot_t prot, int flags, caddr_t handle, vm_offset_t foff)
int
vmspaceprotect(struct vmspace *vs, caddr_t va, unsigned sz, int set_max,
vm_prot_t new_prot)
int
vmspaceaccess(struct vmspace *vs, caddr_t va, unsigned sz, int prot)
void
vmspacepageable(struct vmspace *vs, caddr_t va, unsigned sz)
void
vmspacenotpageable(struct vmspace *vs, caddr_t va, unsigned sz)
int
vmspaceactivate(struct vmspace *vs, caddr_t va, unsigned sz)
int
vmspaceinherit(struct vmspace *vs, caddr_t va, unsigned sz,
vm_inherit_t new_inheritance)
DESCRIPTION
Access to the facilities of the virtual memory system is made available
via the "vmspace" program interface, which provides the methods to create
new address spaces and allocate contents within them. In addition, the
attributes and contents of the allocated address space can be adjusted as
needed by the kernel to suite its needs. These functions can be applied
to both kernel and user program address spaces, however, the kernel
program has its own special interfaces as well (see kmem(9)).
Each program has a small structure (struct vmspace) that is used to
describe the characteristics of a particular address space. Modifications
to an address space may be done from other process or thread contexts,
however they currently may not be done from interrupt level as they may
block for memory allocation or contention (a special exception is made
for kernel memory allocation -- see kmem(9)).
The vmspacefork() function creates a user address space for a new
process by replicating an existing processes user address space. The
vmspacefree() function reclaims a user address space and any resources
consumed by it. The vmspaceallocate() function reserves a region of
address space of a requested size. This region can either begin at a
specific desired location, or the caller can request that a search for an
adjacent, allocatable region be performed in order to locate a free
portion of address space. The vmspacedelete() function deallocates a
region of an address space, along with any resources consumed within it.
The vmspacemmap() function provides an interface similar the the mmap(2)
system call to associate a region of address space with a device driver
or file, and adjust the attributes of the region of memory to suite the
needs of a mapped object.
The vmspaceprotect() function adjusts the current and maximum memory
protection of a region of an address space, to alter the level of access
allowed by programs. Similarly, the function vmspaceaccess() can be used
to check if a operation associated with a given memory protection level
can be performed over a specified region of an address space.
The vmspacenotpageable() function forces a region of an address space to
be entirely resident and allocated (however, not actively mapped -- just
insured to be resident). The vmspacepageable() function releases this
restriction, allowing the memory to become reclaimable again. The
vmspaceactive() function forces a region of address space to become
addressable without fault at its maximum protection level (this will
cause any copy-on-write portions of the region to have distinct copies as
a side-effect), and can be used in concert with the resident state
functions.
The vmspaceinherit() function can be used to assign the inheritance
attribute of regions of address space to determine the disposition of any
contents upon the next address space replication operation (contents
stays with original, contents passes to the copy, contents are copied).
RETURN VALUES
The vmspacefork() function returns the address of the vmspace instance
associated with the new user address space copy. The vmspaceallocate(),
vmspacemmap(), vmspaceprotect(), vmspaceaccess(), and
vmspaceactivate() functions returns the status of the requested
operation attempt. The vmspaceinherit() function returns failure if an
unimplemented inheritance type is requested.
SEE ALSO
kmem(9), mmap(2), fork(2), exit(2)
386BSD Release 1.0 August 29, 1994 2