~ubuntu-branches/ubuntu/precise/manpages-posix/precise

1 by Francesco Paolo Lovergine
rules: linking manpages-posix not manpages.
1
.\" Copyright (c) 2001-2003 The Open Group, All Rights Reserved 
2 by Francesco Paolo Lovergine
* Alligned to linux main manpages edition.
2
.TH "MSYNC" P 2003 "IEEE/The Open Group" "POSIX Programmer's Manual"
1 by Francesco Paolo Lovergine
rules: linking manpages-posix not manpages.
3
.\" msync 
4
.SH NAME
5
msync \- synchronize memory with physical storage
6
.SH SYNOPSIS
7
.LP
8
\fB#include <sys/mman.h>
9
.br
10
.sp
11
int msync(void *\fP\fIaddr\fP\fB, size_t\fP \fIlen\fP\fB, int\fP \fIflags\fP\fB);
12
\fP
13
\fB
14
.br
15
\fP
16
.SH DESCRIPTION
17
.LP
18
The \fImsync\fP() function shall write all modified data to permanent
19
storage locations, if any, in those whole pages
20
containing any part of the address space of the process starting at
21
address \fIaddr\fP and continuing for \fIlen\fP bytes. If no
22
such storage exists, \fImsync\fP() need not have any effect. If requested,
23
the \fImsync\fP() function shall then invalidate
24
cached copies of data.
25
.LP
26
The implementation shall require that \fIaddr\fP be a multiple of
27
the page size as returned by \fIsysconf\fP().
28
.LP
29
For mappings to files, the \fImsync\fP() function shall ensure that
30
all write operations are completed as defined for
31
synchronized I/O data integrity completion. It is unspecified whether
32
the implementation also writes out other file attributes.
33
When the \fImsync\fP() function is called on MAP_PRIVATE mappings,
34
any modified data shall not be written to the underlying object
35
and shall not cause such data to be made visible to other processes.
36
It is unspecified whether data in MAP_PRIVATE mappings has any
37
permanent storage locations.   \ The effect of \fImsync\fP() on a
38
shared memory object or a typed memory object is unspecified.
39
The behavior of this function is unspecified if the mapping was not
40
established by a call to \fImmap\fP().
41
.LP
42
The \fIflags\fP argument is constructed from the bitwise-inclusive
43
OR of one or more of the following flags defined in the \fI<sys/mman.h>\fP
44
header:
45
.TS C
46
center; l2 l.
47
\fBSymbolic Constant\fP	\fBDescription\fP
48
MS_ASYNC	Perform asynchronous writes.
49
MS_SYNC	Perform synchronous writes.
50
MS_INVALIDATE	Invalidate cached data.
51
.TE
52
.LP
53
When MS_ASYNC is specified, \fImsync\fP() shall return immediately
54
once all the write operations are initiated or queued for
55
servicing; when MS_SYNC is specified, \fImsync\fP() shall not return
56
until all write operations are completed as defined for
57
synchronized I/O data integrity completion. Either MS_ASYNC or MS_SYNC
58
is specified, but not both.
59
.LP
60
When MS_INVALIDATE is specified, \fImsync\fP() shall invalidate all
61
cached copies of mapped data that are inconsistent with the
62
permanent storage locations such that subsequent references shall
63
obtain data that was consistent with the permanent storage
64
locations sometime between the call to \fImsync\fP() and the first
65
subsequent memory reference to the data.
66
.LP
67
If \fImsync\fP() causes any write to a file, the file's \fIst_ctime\fP
68
and \fIst_mtime\fP fields shall be marked for
69
update.
70
.SH RETURN VALUE
71
.LP
72
Upon successful completion, \fImsync\fP() shall return 0; otherwise,
73
it shall return -1 and set \fIerrno\fP to indicate the
74
error.
75
.SH ERRORS
76
.LP
77
The \fImsync\fP() function shall fail if:
78
.TP 7
79
.B EBUSY
80
Some or all of the addresses in the range starting at \fIaddr\fP and
81
continuing for \fIlen\fP bytes are locked, and
82
MS_INVALIDATE is specified.
83
.TP 7
84
.B EINVAL
85
The value of \fIflags\fP is invalid.
86
.TP 7
87
.B EINVAL
88
The value of \fIaddr\fP is not a multiple of the page size {PAGESIZE}.
89
.TP 7
90
.B ENOMEM
91
The addresses in the range starting at \fIaddr\fP and continuing for
92
\fIlen\fP bytes are outside the range allowed for the
93
address space of a process or specify one or more pages that are not
94
mapped.
95
.sp
96
.LP
97
\fIThe following sections are informative.\fP
98
.SH EXAMPLES
99
.LP
100
None.
101
.SH APPLICATION USAGE
102
.LP
103
The \fImsync\fP() function is only supported if the Memory Mapped
104
Files option and the Synchronized Input and Output option are
105
supported, and thus need not be available on all implementations.
106
.LP
107
The \fImsync\fP() function should be used by programs that require
108
a memory object to be in a known state; for example, in
109
building transaction facilities.
110
.LP
111
Normal system activity can cause pages to be written to disk. Therefore,
112
there are no guarantees that \fImsync\fP() is the only
113
control over when pages are or are not written to disk.
114
.SH RATIONALE
115
.LP
116
The \fImsync\fP() function writes out data in a mapped region to the
117
permanent storage for the underlying object. The call to
118
\fImsync\fP() ensures data integrity of the file.
119
.LP
120
After the data is written out, any cached data may be invalidated
121
if the MS_INVALIDATE flag was specified. This is useful on
122
systems that do not support read/write consistency.
123
.SH FUTURE DIRECTIONS
124
.LP
125
None.
126
.SH SEE ALSO
127
.LP
128
\fImmap\fP() , \fIsysconf\fP() , the Base Definitions volume of
129
IEEE\ Std\ 1003.1-2001, \fI<sys/mman.h>\fP
130
.SH COPYRIGHT
131
Portions of this text are reprinted and reproduced in electronic form
132
from IEEE Std 1003.1, 2003 Edition, Standard for Information Technology
133
-- Portable Operating System Interface (POSIX), The Open Group Base
134
Specifications Issue 6, Copyright (C) 2001-2003 by the Institute of
135
Electrical and Electronics Engineers, Inc and The Open Group. In the
136
event of any discrepancy between this version and the original IEEE and
137
The Open Group Standard, the original IEEE and The Open Group Standard
138
is the referee document. The original Standard can be obtained online at
139
http://www.opengroup.org/unix/online.html .