Definition
L2 cache is a static RAM memory that the central processing unit uses to store frequently used instructions and data. Its purpose is to improve the CPU’s data access speed by avoiding sluggish RAM memory access.
When the CPU wants to access data, it starts with the cache. If the information is available here, it doesn’t have to access the slower primary memory.
Memory Hierarchy in Modern Computer Systems
- Register: The smallest (typically a few bytes per register) and fastest (nanoseconds) cache type placed inside the CPU core. It holds the data the CPU is currently processing.
- L1 cache: It is also integrated into the CPU core and split into two: one for instructions (L1i) and the other for data (L1d). This cache allows the CPU to access the most critical data and instructions as quickly as possible, enabling it to perform at its highest speed.
- L2 cache: It is found either on the CPU core (on-die) or on a separate chip near the CPU. This cache stores data that isn’t as frequently accessed as the L1 cache but is still needed relatively often.
- L3 cache: This cache is shared across multiple CPU cores and stores less frequently accessed data and instructions.
- Primary memory (RAM): This is the main storage that the CPU uses to store active data and programs.