msync

Synchronizes a mapped file.

Format

#include  <mman.h>

int msync  (void *addr, size_t len, int
           flags);

Arguments

addr
The address of the region that you want to synchronize.
len
The length in bytes of the region that you want to synchronize.
flags
One of the following symbolic constants defined in the <mman.h> header file:
MS_SYNC  Synchronous cache flush 
MS_ASYNC  Asynchronous cache flush 
MS_INVALIDATE  Invalidate cashed pages 

Description

This function controls the caching operations of a mapped file region. Use msync to:

The addr and len arguments specify the region to be synchronized. The len argument must be a multiple of the page size as returned by sysconf(_SC_PAGE_SIZE); otherwise, the length of the region is rounded up to the next multiple of the page size.

If the flags argument is set to:
flags Argument   Then the msync Function... 
MS_SYNC  Does not return until the system completes all I/O operations. 
MS_ASYNC  Returns after the system schedules all I/O operations. 
MS_ INVALIDATE  Invalidates all cached copies of the pages. The operating system must obtain new copies of the pages from the file system the next time the application references them. 

After a successful call to the msync function with the flags argument set to:

See also read, write, and sysconf in this section.

Return Values
Indicates success. 
-1  Indicates an error; errno is set to one of the following values:

  • EIO - An I/O error occurred while reading from or writing to the file system.

  • ENOMEM - The range specified by [addr, addr + len] is invalid for a process' address space, or the range specifies one or more unmapped pages.

  • EINVAL - The addr argument is not a multiple of the page size as returned by sysconf(_SC_PAGE_SIZE).

  • EFAULT - The range [addr, addr + len] includes an invalid address.
 


Previous Page | Next Page | Table of Contents | Index