osfmk/man/vm_msync.html
Function - Synchronize the specified region of virtual memory.
**kern\_return\_t vm\_msync**** (vm\_task\_t **target\_task,** vm\_address\_t **address,** vm\_size\_t **size,** target\_task **sync\_flags** );**
target_task[in task send right] The port for the task whose address space contains the region.
address[in scalar] The starting address for the region.
size[in scalar] The number of bytes in the region.
sync_flags[in scalar] The bit-wise OR of flags affecting the synchronization. Specifying both VM_SYNC_SYNCHRONOUS and VM_SYNC_ASYNCHRONOUS is invalid.
VM_SYNC_INVALIDATE Flushes pages in the range. Only precious pages are returned to the memory manager unless either VM_SYNC_SYNCHRONOUS or VM_SYNC_ASYNCHRONOUS is also set.
VM_SYNC_SYNCHRONOUS Writes dirty and precious pages back to the memory manager, waits for pages to reach backing storage.
VM_SYNC_ASYNCHRONOUS Writes dirty and precious pages back to the memory manager, returns without waiting for pages to reach backing storage.
The vm_msync function synchronizes the contents of a memory range with its backing store image by flushing or cleaning the contents of the specified range to the range's memory manager, engaging in a synchronization protocol with the manager ( memory_object_synchronize ). The client does not return from this call until the memory manager responds (to the kernel) with memory_object_synchronize_completed.
This interface is machine word length specific because of the virtual address parameter.
KERN_INVALID_ADDRESS The address is illegal or specifies a non-allocated region.
Functions: memory_object_synchronize, memory_object_synchronize_completed.