Museum

Home

Lab Overview

Retrotechnology Articles

⇒ Online Manual

Media Vault

Software Library

Restoration Projects

Artifacts Sought

Related Articles

getpagesize(2)

mmap(2)

munmap(2)



  msync(2)                            CLIX                            msync(2)



  NAME

    msync - Synchronizes memory with physical storage

  LIBRARY

    Standard C Library (libc.a)

  SYNOPSIS

    #include <sys/types.h>

    #include <sys/mman.h>

    int msync(
      caddr_t addr ,
      size_t len ,
      int flags );

  PARAMETERS

    addr    Specifies a page-aligned address at which to start the
            synchronization.

    len     Specifies the number of bytes to synchronize.

    flags   Specifies operations, as described in the DESCRIPTION section.

  DESCRIPTION

    The msync() function writes out all modified pages in the range [addr,
    addr + len] to their permanent storage location.  The msync() function
    optionally invalidates pages in the range so that further references to
    them will cause the system to obtain them from their permanent storage
    locations.

    Values for flags are defined in the <mman.h> header file as follows:

    MS_SYNC         /* synchronized write */
    MS_ASYNC        /* asynchronous write */
    MS_INVALIDATE   /* invalidate mappings */


    Specifying MS_ASYNC causes msync() to return after all I/O operations are
    scheduled.  The buffers (in the kernel) that represent the pages are
    marked for a delayed write.  The pages are in the kernel buffer cache, but
    they are not physically on the disk.  The point at which the pages
    actually appear on disk is not defined.

    MS_SYNC causes msync() to return only after all I/O is complete and the
    pages are on the disk.



  2/94 - Intergraph Corporation                                              1






  msync(2)                            CLIX                            msync(2)



    MS_INVALIDATE informs msync() to invalidate cached copies from memory,
    requiring them to be fetched from the permanent storage location upon the
    next reference.  Note:  the MS_INVALIDATE operation only works on pages
    obtained with the mmap() function.

  RETURN VALUES

    The msync() function returns a value of 0 if successful.  If unsuccessful,
    it returns a value of -1.

  ERRORS

    The msync() function fails if any of the following are true:

    [EIO]  An I/O error occurred while writing to the file system.

    [ENOMEM]
           Addresses in the range [addr, addr + len] are outside the valid
           address space of the process.

    [EINVAL]
           The addr parameter is not a multiple of the system pages size as
           returned by getpagesize().

    [EINVAL]
           The flags parameter is not a value.  This means that the flags
           field is not one of the following:

           MS_SYNC
           MS_ASYNC
           (MS_SYNC | MS_INVALIDATE)
           (MS_ASYNC | MS_INVALIDATE)


           In the above list, the pipe symbol (|) indicates the logical OR
           operation.

    [EBUSY]
           MS_INVALIDATE was specified and a page was encountered that was
           locked in memory.

  RELATED INFORMATION

    Functions:  getpagesize(2), mmap(2), munmap(2)










  2                                              Intergraph Corporation - 2/94




Typewritten Software • bear@typewritten.org • Edmonds, WA 98026