Refresh Function
Msync ()
The process changes the shared content in the ing space and does not directly return to the disk file. This operation is usually performed only after munmap () is called. You can call the msync () function to synchronize disk files with the shared memory.
Int msync (void * addr, size_t len, int flags );
Header file
# Include <sys/mman. h>
Addr: The address mapped to the process space;
Len: the size of the ing space;
Flags: refresh parameter settings. values include MS_ASYNC, MS_SYNC, and MS_INVALIDATE.
Where:
When the value is MS_ASYNC asynchronous), the call will return immediately, not until the update is complete;
When the value is MS_SYNC), the call will return after the update is complete;
When MS_INVALIDATE is used to notify the process using the shared area that the data has changed), other Mappings of the file become invalid after the shared content is changed, this allows other processes that share the file to obtain the latest value;
Return Value
If the call succeeds, 0 is returned. If the call fails,-1 is returned;
Possible Errors
EBUSY/EINVAL/ENOMEM
Unbind memory ing
Munmap
Header file
# Include <unistd. h>
# Include <sys/mman. h>
Defines the int munmap (void * start, size_t length) function );
Function Description: munmap () is used to cancel the ing memory start address specified by the start parameter, and the length parameter is the memory size to be canceled. When the process ends or other programs are executed using exec functions, the ing memory is automatically removed, but the ing is not removed when the corresponding file description is disabled.
If the ing is successfully removed, 0 is returned. Otherwise,-1 is returned. The error cause is stored in the error code EINVAL in errno.
The start or length parameter is invalid.