No buffer IO and no buffer IO

Source: Internet
Author: User

  1. First, no cache means that there is no cache at the user layer, but for the kernel, it is still cached.

  2. If you want to write data to a file, that is, the hard disk), the kernel first writes the data to the buffer storage set in the kernel. write () System Call ), when the buffer is full, it is actually written to the disk.

  3. I/O with buffer is to create a buffer stream buffer at the user layer), and improve performance by reducing the number of times the system calls read () and write ().

    For example, you can call fwrite multiple times to write data to the stream buffer. When the stream buffer is full, you can call write () again to write data to the kernel buffer.

  4. Summary:

    Data Flow Path for no buffer I/O operations: Data-> kernel buffer-> Disk

    Data Flow Path with buffer I/O operations: Data-> stream buffer-> kernel buffer-> Disk


  5. Standard IO is the IO with cache, providing three types of Cache

    Full cache: IO operations are performed only when the standard I/O cache is filled. files on the disk are usually fully cached.

    Row cache: IO operations are performed only when the input/output encounters a line break or when the cache is full. stdin and stdout are usually row-cached.

    No cache: stderr is usually not cached because it must be output as soon as possible.

    What kind of buffer is irrelevant to the function used, but it is related to what type of file to read and write.

  6. The implementation of the standard C library for file operations with cache. When the first time a file operation function with cache is called, the standard library automatically does not configure memory and reads a fixed size of memory and stores it in the cache. In the future, each read/write operation will not be performed directly on files on the hard disk, but on the cache in the memory.

  7. File Operations without caching are generally system calls provided by the system.

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.