Synchronize memory with physical storage.
Standard C Library (libc.a).
The msync subroutine controls the caching operations of a mapped file or shared memory region. Use the msync subroutine to transfer modified pages in the region to the underlying file storage device.
If the application has requested Single UNIX Specification, Version 2 compliant behavior, then the mapped file’s last data modification and last file status change timestamps are marked for update upon successful completion of the msync subroutine call if the file has been modified.
Item | Description |
---|---|
addr | Specifies the address of the region to be synchronized. Must be a multiple of the page size returned by the sysconf subroutine using the _SC_PAGE_SIZE value for the Name parameter. |
len | Specifies the length, in bytes, of the region to be synchronized. If the len parameter is not a multiple of the page size returned by the sysconf subroutine using the _SC_PAGE_SIZE value for the Name parameter, the length of the region is rounded up to the next multiple of the page size. |
flags | Specifies one or more of the following symbolic constants
that determine the way caching operations are performed:
|
When successful, the msync subroutine returns 0. Otherwise, it returns -1 and sets the errno global variable to indicate the error.
If the msync subroutine is unsuccessful, the errno global variable is set to one of the following values:
Item | Description |
---|---|
EBUSY | One or more pages in the range passed to the msync subroutine is pinned. |
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 the sysconf subroutine using the _SC_PAGE_SIZE value for the Name parameter, or the flags parameter is invalid. The address of the region is within the process' inheritable address space. |