Library /sys$common/syshlp/helplib.hlb  —  CRTL  msync
    Synchronizes a mapped file.

    Format

      #include  <mman.h>

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

1  –  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 cashed pages
    INVALIDATE

2  –  Description

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

    o  Ensure that modified pages in the region transfer to the
       underlying storage device of the file.

    o  Control the visibility of modifications with respect to file
       system operations.

    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:

    o  MS_SYNC - All previous modifications to the mapped region
       are visible to processes using the read argument. Previous
       modifications to the file using the write function are lost.

    o  MS_INVALIDATE - All previous modifications to the file using
       the write function are visible to the mapped region. Previous
       direct modifications to the mapped region are lost.

    See also read, write, and sysconf.

3  –  Return Values

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

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

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

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

                       o  EFAULT - The range [addr, addr + len]
                          includes an invalid address.
Close Help