A cache, in simpler words, refers to a block of memory used for storing data that is most likely used again. The hard drive and CPU often make use of a cache, just like the web servers and web browsers do. Any cache is made up of numerous entries, known as a pool.
In this article, we will take a look at the Cache Memory according to the GATE Syllabus for CSE (Computer Science Engineering). Read ahead to learn more.
Table of Contents
- What is Cache Memory?
- Accessing Cache Memory
- Types of Cache Memory
- How does the Cache Memory work with the CPU?
- Practice Problems on Cache Memory
- Frequently Asked Questions on Cache Memory
What is Cache Memory?
Cache memory refers to high-speed memory. It is small but faster than RAM (the main memory). The CPU can access the cache comparatively more quickly than its primary memory. Thus, we use it to synchronize with a high-speed CPU and also to improve its overall performance.
Accessing Cache Memory
Only the CPU can access the cache memory. This memory can be the reserved part of a main memory/storage device outside the CPU. The cache holds the data and programs that the CPU uses frequently. Thus, it ensures that the information is instantaneously available for the CPU as and when the CPU needs this information. In simpler words, if the CPU finds the required instructions or data in the system’s cache memory, it does NOT need to access its primary memory or RAM. Thus, it speeds up the performance of the system by operating as a buffer between the RAM and the CPU.
Types of Cache Memory
L1 Cache
This refers to the first level of any cache memory, usually known as the L1 cache or Level 1 cache. In L1 cache memory, a very small memory exists inside the CPU itself. In case the CPU consists of four cores (A quad-core CPU), each core will then have its own L1 cache.
Since this memory exists in the CPU, it can operate at the very same speed as that of the CPU. The actual size of such a memory ranges from 2 kilobytes to 64 kilobytes. The Level 1 cache has two further types of caches: The Instruction cache storing, the instructions that are required by a CPU, along with the data cache storing, the data that is required by a CPU.
L2 Cache
This cache refers to the L2 cache or Level 2 cache. The level 2 cache may reside both inside or outside any given CPU. Here, all the cores of the CPU can consist of their separate (own) level 2 cache, or they can even share a single L2 cache among themselves. Now, in case it’s outside the CPU, it connects with the CPU using a very high-speed bus. Here, the memory size of a cache ranges from 256 kilobytes to 512 kilobytes. If we go for the speed, these are comparatively slower than the Level 1 cache.
L3 Cache
This cache is known as the L3 cache or Level 3 cache. This type of cache isn’t present in all of the processors. Only a few of the high-end processors may contain this type of cache. We use the L3 cache to enhance the overall performance of the L1 and the L2 cache. This type of memory is located outside a CPU. It is also shared by all CPU cores. The memory size of the L3 cache ranges from 1 to 8 megabytes. Though the L3 cache is slower than that of the L1 cache and the L2 cache, it is much faster than that of the RAM or Random Access Memory.
How does the Cache Memory work with the CPU?
Whenever a CPU needs the data/information, it first of all looks inside its L1 cache. In case it doesn’t find anything in the L1 cache, then it looks inside L2. If it again does not find any data in L2, it then looks into L3. Now, if the information is found in the memory of the cache, then it is called a cache hit. On the other hand, if data isn’t found inside this cache, then it is known as a cache miss.
Finally, if the information isn’t available in any cache memory, it looks inside the RAM. Now, if the RAM also doesn’t contain the data, it will get that information from the system’s Hard Disk Drive.
Thus, when we start a computer for the first time or when we open an application for the first time, then the data isn’t available in RAM or in cache memory. In this case, the CPU directly gets the information from the hard disk drive. Thus, when we start our computer or whenever we open an application, the CPU can get its actual data from the RAM or the cache memory.
Practice Problems on Cache Memory
1. When the data or information is found in a cache memory, then it is known as the ________________.
A. MISS
B. HIT
C. ERROR
D. FOUND
Answer – B. HIT
2. Which of these is not a written policy in order to avoid Cache Coherence?
A. Buffered write
B. Write back
C. Write within
D. Write through
Answer – C. Write within
3. ______________ refers to the transfer between the CPU and the Cache.
A. Set transfer
B. Block transfer
C. Associative transfer
D. Word transfer
Answer – D. Word transfer
4. Whenever the data at any location in the cache happens to be different from the information located in the system’s main memory, then the cache is known as _____________.
A. Inconsistent
B. Unique
C. Fault
D. Variable
Answer – A. Inconsistent
Frequently Asked Questions on Cache Memory
What is cache memory? Why is it used?
Cache refers to the temporary memory termed the “CPU cache memory” officially. This chip-based feature of a computer lets users access certain data and information in a quicker manner than if they access it from the computer’s main hard drive. Thus, cache memory helps in quicker access to information.
What are the 3 types of cache memory?
There are a total of three general levels of cache:
- The L1 cache, known as the primary cache, is very fast, but it is relatively small. It is embedded usually in the processor chip in the form of the CPU cache.
- The L2 cache, also known as the secondary cache, is often comparatively more capacious than the L1 cache.
- The Level 3 or L3 cache refers to a specialized memory that is developed in order to improve the actual performance of the L1 and L2.
How do caches work?
The information or data present in a cache is stored generally in fast access hardware like Random-access memory or RAM, and it may also be with a software component. The primary purpose of the cache is to increase the overall data retrieval performance. It does so by reducing the necessity of a system to access the slower storage layer underlying in the background.
What is cache in simple terms?
A cache, in simpler words, refers to a block of memory used for storing data that is most likely used again. The hard drive and CPU often make use of a cache, just like the web servers and web browsers do. Any cache is made up of numerous entries, known as a pool.
Keep learning and stay tuned to get the latest updates on the GATE Exam along with Eligibility Criteria, GATE Syllabus for CSE (Computer Science Engineering), GATE CSE Notes, GATE CSE Question Paper, and more.
Also Explore,
Comments