VMF(3)

NAME
vminit, vmopen, vmclose, vmmapseg, vmmodify, vmlock, vmunlock, vmclrseg, vmflush, - disk based virtual memory routines

SYNOPSIS

#include <vmf.h>

struct vspace {
	int     v_fd;           /* file for swapping */
	off_t   v_foffset;      /* offset for computing file addresses */
	int     v_maxsegno;     /* number of segments in this space */
	};

struct	vseg {                    /* structure of a segment in memory */
	struct	dlink	s_link;		/* for linking into lru list */
	int	s_segno;        	/* segment number */
	struct	vspace	*s_vspace;      /* which virtual space */
	int	s_lock_count;
	int     s_flags;
	union
		{
		int	_winfo[WORDSPERSEG];	/* the actual segment */
		char	_cinfo[BYTESPERSEG];
		} v_un;
	};
#define	s_winfo	v_un._winfo
#define	s_cinfo	v_un._cinfo

int	vminit(nseg);
	int nseg;

int	vmopen(space, filename);
	struct vspace *space;
	char	*filename;

struct	vseg	*vmmapseg(space, segno);
	struct	vspace	*space;
	int	segno;

void	vmlock(seg);
	struct	vseg *seg;

void	vmunlock(seg);
	struct	vseg *seg;

void	vmclrseg(seg);
	struct	vseg *seg;

void	vmmodify(seg);

void	vmflush();

void	vmclose(space);
	struct	vspace *space;

DESCRIPTION
This library provides a standard set of routines for managing large virtual memory spaces. It supports creation of multiple concurrent virtual spaces, mapping of virtual pages into real memory, a lock/unlock mechanism, and a capability to clear specified virtual pages.

vminit - This routine initializes the virtual memory system by setting up the pool of in-memory segment buffers. The argument to this function is the number of memory segments to allocate (typically 4 to 8 but can be higher as long as memory can be malloc'd). It must be called before any other "libvmf" routine is called.

vmopen - For each virtual space that a program uses, the program must allocate an instance of the space structure ('struct vspace'). This routine is used to initialize a virtual space structure using the specified address of a space structure and the name of the file that will serve as swap file for the space. If the second argument is NULL an invisible temporary file is used rather than a named (permanent) file.

vmclose - This routine is used to close the UNIX file descriptor associated with the swap file for a virtual space. Any modified in-memory segments belonging to the specified address space are flushed to the paging file.

vmmapseg - This routine is the primary interface to the virtual memory mechanism. It is executed with a specified virtual space address and a segment number (between 0 and 511), and returns a pointer to an in-memory page containing the specified segment.

vmmodify - Whenever a program modifies the data of a segment, it is the program's responsibility to inform the virtual memory system of the modification. This function is also available as a macro (VMMODIFY) for use in-line.

vmlock - This routine increments the lock count of the specified segment buffer. A buffer with a nonzero lock count is locked and cannot be swapped out.

vmunlock - This routine decrements the lock count of the specified buffer. It is a serious error to decrement the count below zero (lock underflow).

vmclrseg - This routine clears the user data area (page) of the specified segment buffer. vmflush - This routine simply swaps out all segments that are marked as modified.

BUGS
Not as transparent (or as fast) as a larger hardware address space.

There is no automatic segment crossing capability, the application must check if a virtual address crosses page/segment boundaries and perform a vmmapseg call.

SEE ALSO
There is a nroff document (using the -ms macros) in the libvmf source directory which goes into more details about the vm functions.