vm_write Kernel Service

Purpose

Initiates page-out for a page range in the address space.

Syntax

#include <sys/types.h>
#include <sys/errno.h>
#include  <sys/vmuser.h>

int vm_write (vaddr, nbytes, force)
int  vaddr;
int  nbytes;
int  force;

Description

The vm_write kernel service initiates page-out for pages that intersect the address range (vaddr, vaddr + nbytes).

If the force parameter is nonzero, modified pages are written to disk regardless of how recently they have been written.

Page-out is initiated for each modified page. An unchanged page is left in memory with its reference bit set to 0. This makes the unchanged page a candidate for the page replacement algorithm.

The caller must have write access to the specified pages.

The initiated I/O is asynchronous. The vms_iowait kernel service can be called to wait for I/O completion.

Note: The vm_write subroutine is not supported for use on large pages.

Parameters

Item Description
vaddr Specifies the address of the first byte of the page range for which a page-out is desired.
nbytes Specifies the number of bytes starting at the byte specified by the vaddr parameter. This parameter must be nonnegative. All of the bytes must be in the same virtual memory object.
force Specifies a flag indicating that a modified page is to be written regardless of when it was last written.

Execution Environment

The vm_write kernel service can be called from the process environment only.

Return Values

Item Description
0 Indicates a successful completion.
EINVAL Indicates one of these four errors:
  • A region is not defined.
  • A region is an I/O region.
  • The length specified by the nbytes parameter is negative.
  • The address range crosses a virtual memory object boundary.
  • One or more large pages lie in the target page range.
EACCES Indicates that access does not permit writing.
EIO Indicates a permanent I/O error.