Page 51 - Computer_Science_F5
P. 51
you need a book to access some information, you check your locker first before
Computer Science (c) Making Space (Cache replacement): If you need a book that is not in your
rushing to the library. Similarly, the cache needs to identify if the information
the processor needs is already inside. This quick check saves valuable time
compared to accessing the main memory for everything.
FOR ONLINE READING ONLY
locker, you go to the library to get it. Once you find it, you realise that your
locker is full. You need to decide which book to take out to make space for the
new one. Cache replacement algorithms face the same dilemma. They decide
which existing information in the cache to discard to make room for new data
the processor needs.
Types of cache memory
Cache memory is categorized into levels based on its proximity and accessibility to
the processor, as shown in Figure 1.40. There are three general cache levels: Level
1 (L1), Level 2 (L2), and Level 3 (L3).
Main
CPU Level 1(L1) Level 2(L2) Level 3(L3) memory
cache
cache
cache
Fastest Fast Less fast Slow
Figure 1.40: Cache memory levels
Level 1 cache (L1): The primary cache Level 3 cache (L3): This cache further
closest to the CPU, offering the fastest enhances performance with a larger
access time. It is small and stores only capacity and speed double that of main
the most frequently used data and memory (DRAM). It supplements L1
instructions for minimal delay. and L2 caches.
Level 2 cache (L2): The secondary Recently, trends have shifted towards
cache with larger capacity than L1. It can integrating all three levels of cache
be on the CPU chip or a separate chip
connected via a high-speed bus. It stores memory onto the CPU itself, providing
a broader range of data and instructions faster access times and a more
for the processor. streamlined system design.
42
for Advanced Secondary Schools
Computer Science Form 5.indd 42 23/07/2024 12:32