Cache Memory And Its Working:
Cache
memory is a very high-speed semiconductor memory which can speed up CPU. It
acts as a buffer between the CPU and main memory. It is used to hold those
parts of data and program which are most frequently used by CPU. The parts of
data and programs are transferred from disk to cache memory by operating
system, from where CPU can access them.
Static
RAM (SRAM)
is used as cache memory to store the most recently used data and
instructions. SRAM provides the processor with faster access to the data than retrieving
it from the slower dynamic RAM (DRAM), or main memory.
The
three most common types of cache memory are:
1.
L1: L1 cache is internal cache and is
integrated into the CPU.
2.
L2: L2 cache is external cache and was
originally mounted on the motherboard near the CPU. L2 cache is now integrated
into the CPU.
3.
L3: L3 cache is used on some high-end
workstations and server CPUs.
Cache
Memory in Details:
Cache
memory is a high-speed memory, which is small in size but faster than the main
memory (RAM). The CPU can access it more quickly than the primary memory. So,
it is used to synchronize with high-speed CPU and to improve its performance.
Cache
memory can only be accessed by CPU. It can be a reserved part of the main
memory or a storage device outside the CPU. It holds the data and programs
which are frequently used by the CPU. So, it makes sure that the data is
instantly available for CPU whenever the CPU needs this data. In other words,
if the CPU finds the required data or instructions in the cache memory, it
doesn't need to access the primary memory (RAM). Thus, by acting as a buffer
between RAM and CPU, it speeds up the system performance.
Types
of Cache Memory:
1.
L1: It is the first level of cache
memory, which is called Level 1 cache or L1 cache. In this type of cache
memory, a small amount of memory is present inside the CPU itself. If a CPU has
four cores (quad core CPU), then each core will have its own level 1 cache. As this
memory is present in the CPU, it can work at the same speed as of the CPU. The
size of this memory ranges from 2KB to 64 KB. The L1 cache further has two
types of caches: Instruction cache, which stores instructions required by the
CPU, and the data cache that stores the data required by the CPU.
2.
L2: This cache is known as Level 2 cache
or L2 cache. This level 2 cache may be inside the CPU or outside the CPU. All
the cores of a CPU can have their own separate level 2 cache, or they can share
one L2 cache among themselves. In case it is outside the CPU, it is connected
with the CPU with a very high-speed bus. The memory size of this cache is in
the range of 256 KB to the 512 KB. In terms of speed, they are slower than the
L1 cache.
3. L3: It is known as Level 3 cache or L3 cache. This cache is not present in all the processors; some high-end processors may have this type of cache. This cache is used to enhance the performance of Level 1 and Level 2 cache. It is located outside the CPU and is shared by all the cores of a CPU. Its memory size ranges from 1 MB to 8 MB. Although it is slower than L1 and L2 cache, it is faster than Random Access Memory (RAM).
Working
Process of Cache Memory:
When
CPU needs the data, first of all, it looks inside the L1 cache. If it does not
find anything in L1, it looks inside the L2 cache. If again, it does not find
the data in L2 cache, it looks into the L3 cache. If data is found in the cache
memory, then it is known as a cache hit. On the contrary, if data is not found
inside the cache, it is called a cache miss.
If
data is not available in any of the cache memories, it looks inside the
Random-Access Memory (RAM). If RAM also does not have the data, then it will
get that data from the Hard Disk Drive. So, when a computer is started for the
first time, or an application is opened for the first time, data is not
available in cache memory or in RAM. In this case, the CPU gets the data
directly from the hard disk drive. Thereafter, when you start your computer or
open an application, CPU can get that data from cache memory or RAM.
The advantages of cache memory are as follows:
1. Cache memory is faster than main memory.
2. It consumes less access time as compared to main memory.
3. It stores the program that can be executed within a short period of time.
4. It stores data for temporary use.
Disadvantages
The disadvantages of cache memory are as follows:
1. Cache memory has limited capacity.
0 Comments