United States-English |
|
|
HP-UX Reference > Mmsync(2)HP-UX 11i Version 3: February 2007 |
|
NAMEmsync() — synchronize the memory of a mapped file with physical storage SYNOPSIS#include <sys/mman.h> int msync( void *addr, size_t len, int flags ); Parameters
DESCRIPTIONThe msync() function writes all modified copies of pages over the range [addr, addr+len] to the underlying hardware, or invalidates any copies so that further references to the pages will be obtained by the system from their permanent storage locations. addr and len specify the region to be synchronized. If these are not the address and length of a region created by a previous successful call to mmap(), msync() returns an error. The behavior of msync() upon a region created with the MAP_ANONYMOUS or MAP_PRIVATE flags is undefined. If msync() causes any write to the file, then the file's st_ctime and st_mtime fields are marked for update. Performance ConsiderationsThe following performance considerations only apply when using the MS_INVALIDATE option with msync(). These performance constraints do not apply when either MS_ASYNC or MS_SYNC are exclusively used with msync(). Direct read/write references to portions of a mapped memory region currently undergoing an msync() operation (with MS_INVALIDATE specified), may be blocked until all scheduled write operations are completed. This is especially true when performing an msync() operation across a relatively large address range that requires many individual write operations to be scheduled out to the underlying hardware. HP-UX will schedule a separate write operation for each contiguous group of modified pages on disk. As more write operations are queued out to the device, the overall suspension time of direct read/write references to the same portions of the memory region will generally increase. The suspension times of direct read/write references can be reduced by issuing msync() requests over smaller portions of the memory region, but issuing them more frequently than a corresponding larger synchronization request. This will serve to more evenly distribute I/O activity across the mapped file, while reducing the number of write operations per msync(). RETURN VALUEmsync() returns the following values:
ERRORSThe msync() function will fail if:
APPLICATION USAGEThe msync() function should be used by programs that require a memory object to be in a known state. For example, in building transaction facilities. Normal system activity can cause pages to be written to disk. Therefore, there are no guarantees that msync() is the only control over when pages are or are not written to disk. |
Printable version | ||
|