MMAP and read/write

Source: Internet
Author: User

Comparison between MMAP and read/write on File Access

We know that files accessed through MMAP or read/write must be cached in the kernel. When you need to read and write content from the file, the files are copied to the cache in the kernel for communication.

1. in read/write mode, the user must specify the number of reads to the kernel, and then copy the obtained content from the kernel cache to the user space. The write process also needs to be roughly the same.

2. MMAP maps a part of the file to the user space to map the previously described kernel cache to the user space, so that the content can be read and written directly through the kernel buffer pool, in this way, the back-and-forth copying between the kernel and the user space is reduced, so it is usually faster.

Therefore, the advantage of MMAP is that compared with read/write, it reduces the copy overhead of a kernel cache to the user space memory. However, when creating a ing, MMAP must specify a ing area, therefore, this method is only applicable to updating and reading a fixed size file area, rather than constantly writing content to the file in an increasing manner.

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.