1MSYNC(2) Linux Programmer's Manual MSYNC(2)
2
3
4
6 msync - synchronize a file with a memory map
7
9 #include <sys/mman.h>
10
11 int msync(void *start, size_t length, int flags);
12
14 msync() flushes changes made to the in-core copy of a file that was
15 mapped into memory using mmap(2) back to disk. Without use of this
16 call there is no guarantee that changes are written back before mun‐
17 map(2) is called. To be more precise, the part of the file that corre‐
18 sponds to the memory area starting at start and having length length is
19 updated.
20
21 The flags argument may have the bits MS_ASYNC, MS_SYNC, and MS_INVALI‐
22 DATE set, but not both MS_ASYNC and MS_SYNC. MS_ASYNC specifies that
23 an update be scheduled, but the call returns immediately. MS_SYNC asks
24 for an update and waits for it to complete. MS_INVALIDATE asks to
25 invalidate other mappings of the same file (so that they can be updated
26 with the fresh values just written).
27
29 On success, zero is returned. On error, -1 is returned, and errno is
30 set appropriately.
31
33 EBUSY MS_INVALIDATE was specified in flags, and a memory lock exists
34 for the specified address range.
35
36 EINVAL start is not a multiple of PAGESIZE; or any bit other than
37 MS_ASYNC | MS_INVALIDATE | MS_SYNC is set in flags; or both
38 MS_SYNC and MS_ASYNC are set in flags.
39
40 ENOMEM The indicated memory (or part of it) was not mapped.
41
43 On POSIX systems on which msync() is available, both
44 _POSIX_MAPPED_FILES and _POSIX_SYNCHRONIZED_IO are defined in
45 <unistd.h> to a value greater than 0. (See also sysconf(3).)
46
48 POSIX.1-2001.
49
50 This call was introduced in Linux 1.3.21, and then used EFAULT instead
51 of ENOMEM. In Linux 2.4.19 this was changed to the POSIX value ENOMEM.
52
54 mmap(2)
55 B.O. Gallmeister, POSIX.4, O'Reilly, pp. 128-129 and 389-391.
56
57
58
59Linux 2.4 2003-08-21 MSYNC(2)