CSC114 ยท 0 ยท 5 marks
What is the purpose of cache memory? How sequential access differs from direct access?
What is the purpose of cache memory? How sequential access differs from direct access? [5]
Quick answer
Cache memory is a small, high-speed memory placed between the CPU and the main memory (RAM) in the memory hierarchy.
Cache Memory and Access Methods
Purpose of Cache Memory
Key Purposes:
-
Bridge the Speed Gap: The CPU operates much faster than RAM (CPU registers: 1-2 ns, RAM: ~60 ns). Cache (2-10 ns) sits between them and reduces the time the CPU spends waiting for data.
-
Holds Currently Working Data and Instructions: Cache stores the data and instructions that the CPU is actively using or is likely to use very soon, so the CPU does not have to fetch them repeatedly from the slower main memory.
-
Improves Overall System Performance: By providing fast access to frequently used data, cache reduces the number of slow memory accesses and speeds up program execution.
-
Temporary Storage: Cache is volatile memory (lost when powered off) and has limited capacity (32 KB to 4 MB), but its high speed (made of SRAM with access speed 2-10 ns) makes it ideal for this role.
In summary: Cache memory acts as a fast buffer that keeps the CPU supplied with data quickly, minimizing bottlenecks caused by slower main memory.
Sequential Access vs. Direct Access
| Feature | Sequential Access | Direct Access |
|---|---|---|
| Definition | Data is accessed in a sequential order from start to end | Data can be accessed in any order, directly at any location |
| Order of Access | Must go through all preceding records to reach a target record | Can jump directly to the required record |
| Speed | Slower, especially for records near the end | Faster, as any record is reachable immediately |
| Example | Magnetic tape | Hard disk, RAM |
| Use Case | Reading a file from beginning to end | Searching or updating a specific record |
Brief Explanation:
-
Sequential Access: The file or data is read in a fixed order, from the beginning to the end. To reach a particular piece of data, all the data before it must be read first. This is like rewinding and playing a cassette tape.
-
Direct Access: The file or data can be accessed at any point without going through the preceding data. The system can directly locate and read/write any record. This is like jumping to any track on a CD.
As stated in the notes: "The access in a sequential order from start to end is called sequential access and the file that is accessed in any order is called direct access."
Short on time? The 1, 5 and 10 mark versions of this answer, flashcards and practice sets come with a program pass.