Sei sulla pagina 1di 2

Difference between Cache and Buffer

Cache vs Buffer
Both cache and buffer are temporary storage areas but they differ in many ways. The buffer is mainly found in ram
and acts as an area where the CPU can store data temporarily, for example, data meant for other output devices
mainly when the computer and the other devices have different speeds. This way the computer can perform other
tasks. Cache, on the other hand, is a high-speed storage area that can be part of the main memory or some other
separate storage area like a hard disk. These two methods of caching are referred to as memory caching and disk
caching respectively.

To ensure the high speed, cache is made of static ram rather than dynamic ram used for the other part of the
memory since this is slower. This area is used to store information that is accessed by almost all the programs when
they are running, and this makes it faster rather than searching for this information from the disk each time a
program is running as this would be much slower. The buffer is made up of ordinary ram running in the computer,
and it keeps track of changes happening in a running program by temporarily storing them before the changes are
finally saved in the disk, for example, with word processors where the task being written is first stored in the buffer,
and the word processor later updates the file in the disk with the contents of the buffer.

The buffer is mostly used for input/output processes, for example, in printing. When one sends the documents to be
printed to the printer, the information is stored in a buffer, and the printer can then access this information at its
own pace, and this frees the CPU to perform other tasks. A buffer is also used when burning information to
compact disks where the data to be burned is first stored in the buffer from where it is then transferred to the disk
during the burning process. Cache is mostly used during reading and writing processes to the main disk to make the
process faster by making similar data used by different programs easily accessible.

Cache can either be part of ram or the disk. When the main disk is used as a cache, the process is referred to as disk
caching, and this also works as memory caching where the recently used data is stored in the disk cache. If a
running program wants to access data from the disk, it first checks the disk cache and will only check the disk if the
required data is not available in the disk cache. This makes the data access process much faster since accessing it
from the disk is much slower. A buffer can only be part of ram.

Summary:
1. Cache is a high-speed storage area while a buffer is a normal storage area on ram for temporary storage.
2. Cache is made from static ram which is faster than the slower dynamic ram used for a buffer.
3. The buffer is mostly used for input/output processes while the cache is used during reading and writing
processes from the disk.
4. Cache can also be a section of the disk while a buffer is only a section of the ram.
5. A buffer can be used in keyboards to edit typing mistakes while the cache cannot.
 Buffer
一個暫時的儲存區,通常在 RAM。大部分 buffer 的目的是作為保存區,使 CPU 在將資料傳送至設備前能
處理資料。

因為磁碟讀寫的過程相對地較慢,很多程式先將資料改變紀錄在 buffer 然後再將資料從 buffer 複製到磁碟


動詞將資料搬至暫存區。

 Cache
一種特殊的高速儲存機制,其可為主記憶體的保留區或獨立的高速儲存設備。PC 通常用到兩類 caching:
memory caching and disk caching memory cache 有時稱為 cache store 或 RAM cache,其採用高速 static RAM
(SRAM)而不用主記憶體所用較慢及較便宜的 dynamic RAM (DRAM)。memory caching 是有效的因為大部分
的程式會重複的存取相同的資料或指令,藉由儘可能將這些資訊存在 SRAM,電腦可避免存取較慢的
DRAM。

某些 memory cache 被加入微處理器的架構,例如 Intel 80486 微處理器包含 8KB memory cache 而 Pentium 有
16KB memory cache,此種內部 cache 通常稱為 Level 1 (L1)cache,大部分現代 PC 也有外部 cache memory,
稱為 Level 2 (L2)cache,這些 cache 位於 CPU 和 DRAM 間,如同 L1 caches,L2 caches 由 SRAM 組成但 L2
大的多。

disk caching 和 memory caching 以同樣的原則運作但非採用高速 SRAM,disk cache 用傳統的主記憶體,最


近由磁碟存取的資料存在記憶體暫存區,當程式需要從磁碟存取資料,它先檢查磁碟 cache 看看資料是否在
cache,disk caching 可大大的增加應用程式的效能,因為存取 RAM 裡面 1 byte 資料的速度比存取硬碟 1 byte
資料快數千倍。

當在 cache 中找到資料,稱為 cache hit,而 cache 的有效性由它資料的命中率判定,很多 cache 系統用稱為


smart caching 的技術,此類系統可識別某些類型的常用資料,決定那些資訊應該存在 cache 的策略構成計算
機科學裡更有趣的問題。

Potrebbero piacerti anche