BSD syscall#65
svc · unix #65
msync
Flushes dirty pages of a file-backed mapping back to the underlying vnode.
Prototype
int msync(caddr_t addr, size_t len, int flags);Returns: int
Arguments
| Name | Type | Dir | Description |
|---|---|---|---|
| addr | caddr_t | - | |
| len | size_t | - | |
| flags | int | - |
Version history
| XNU tag | macOS | # |
|---|---|---|
| xnu-1456.1.26 | macOS 10.6 Snow Leopard | 65 |
| xnu-1486.2.11 | — | 65 |
| xnu-1504.15.3 | — | 65 |
| xnu-1504.3.12 | — | 65 |
| xnu-1504.7.4 | — | 65 |
| xnu-1504.9.17 | — | 65 |
| xnu-1504.9.26 | — | 65 |
| xnu-1504.9.37 | — | 65 |
Examples
C — synchronous flush
msync(map, len, MS_SYNC);Notes
msync(2) supports MS_ASYNC (queue the I/O), MS_SYNC (block until completion) and MS_INVALIDATE (drop clean cached pages and force a re-read). For anonymous mappings it is a no-op. macOS routes the write-back through the ubc (unified buffer cache), so the data is visible to subsequent read(2) calls on the same vnode.
Related APIs
mmapmunmapfsyncfdatasyncmadvise