Msync () and munmap ()

Source: Internet
Author: User

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.


Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.