The difference between buffer and cache 
 
 
Buffer is not the same object as the cache operation.
 
Buffer is designed to increase the speed of data exchange between the memory and the hard disk or other i/0 devices
and designed for a degree.
 
The cache is designed to increase the speed of data exchange between the CPU and memory.
 
The instructions and read data that the CPU uses to execute the program are all memory-specific.
In order to improve the speed of data exchange between CPU and memory, the CPU and memory
Cache, which is faster than memory, but expensive, and because it cannot integrate too much within the CPU
IC, so the general cache is relatively small, after Intel and other companies in order to further improve the speed, increase
Level two cache, or even level three cache, which is designed according to the local principle of the program is CPU
Execution of the instruction and access to the data is often in the concentration of a piece, so put this piece of content into the cache cpu
It is not necessary to access the memory, which increases the speed of access. Of course, if the cache does not have the CPU required in the
 
Or to access the memory.
 
The buffer buffers is based on the read/write design of the disk, the decentralized write operation is concentrated to reduce the magnetic
Disk fragments
And the hard drive repeatedly seek to improve system performance. Linux has a daemon that periodically empties the buffer
Content  is written to disk  can also be manually emptied by the Sync command. Let me give you an example.
A ext2 U-disk
I'm going to go inside CP a 3M MP3
But the flash drive's light is not beating.
The  or manual input of the Syncu disk lights will jump up. The buffer is emptied when the device is uninstalled, so there are
When uninstalling a device, wait a few seconds.
Modify the number on the right of vm.swappiness in/etc/sysctl.conf to adjust at the next boot
Swap usage policy. The number range is the larger the 0100 number the more inclined to use swap. Default is 60
 
You can change it and try it. --both are data in RAM.
 
In short, buffer is about to be written to disk and the cache is read from disk.
Buffer is allocated by various processes and is used in areas such as input queues. A simple example, such as a
A process requires multiple fields to be read into the field before all fields are read into full before the process puts the previously read-in fields
Save in buffer.
Cache is often used for I/O on disk
Request, if there are multiple processes to access a file
 
The file is then made into the cache to facilitate the next visit to improve system performance.
 
 
Both speed up the system's reaction speed.