Introduction to Information Technology · Unit 3 · 4 hrs
Computer Memory
Exam-focused notes for Computer Memory (Introduction to Information Technology, CSC114): what the TU syllabus asks and how it has actually been tested, with 10 solved past questions from this unit.
Computer Memory in short
This chapter studies computer memory in depth: how it is measured, how it is organized into a hierarchy, and the various primary and secondary storage devices that hold data.
What this unit covers
- Introduction
- Memory Representation
- Memory Hierarchy
- CPU Registers
- Cache Memory
- Primary Memory
- Secondary Memory
- Access Types of Storage Devices
- Magnetic Tape
- Magnetic Disk
- Optical Disk
- Magneto-Optical Disk
- How the Computer uses its memory
Secondary Memory
2081 · 10 marks
Compare primary memory with secondary memory? Why do we need primary memory in computers? Explain different types of secondary memories used in computers.[10]
Cache Memory
2078 · 5 marks
What is cache memory? How is it different from register? [5]
2075 · 5 marks
What is the purpose of cache memory? How sequential access differs from direct access? [5]
Show solved answerHide answer
Cache Memory and Access Methods
Purpose of Cache Memory
Cache memory is a small, high-speed memory placed between the CPU and the main memory (RAM) in the memory hierarchy.
Key Purposes:
-
Speed Bridging: The CPU operates much faster than RAM (CPU registers: 1-2 ns, RAM: ~60 ns). Cache memory (speed: 2-10 ns) bridges this speed gap so the CPU does not have to wait for data from the slower main memory.
-
Temporary Storage of Active Data: Cache holds the currently working data and instructions that the CPU is likely to need next, reducing the number of times the CPU must access the slower main memory.
-
Performance Improvement: By keeping frequently used data close to the CPU, cache memory significantly speeds up overall system performance.
Key Characteristics of Cache Memory:
- Speed: 2 to 10 nanoseconds
- Size: 32 KB to 4 MB
- Made of SRAM (Static RAM) which uses 4-6 transistors per cell, requires no refreshing, and is faster than DRAM
- Volatile memory (data is lost when power is off)
- Directly accessible by the CPU
Sequential Access vs. Direct Access
These are two different methods of accessing information stored in a file or storage device.
| 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 | Must read all preceding records before reaching the desired one | Can jump directly to the required record |
| Speed | Slower for retrieving a specific record | Faster for retrieving a specific record |
| Example | Reading a tape from beginning | Reading a specific block on a hard disk |
| Flexibility | Less flexible | More flexible |
Summary:
- Sequential access means the file is read from the beginning to the end in order; you cannot skip to a specific location without passing through all previous data.
- Direct access means any part of the file can be read or written at any time without going through the preceding data, making it much more efficient for random retrieval.
0 · 5 marks
What is the purpose of cache memory? How sequential access differs from direct access? [5]
Show solved answerHide answer
Cache Memory and Access Methods
Purpose of Cache Memory
Cache memory is a small, high-speed memory placed between the CPU and the main memory (RAM) in the memory hierarchy.
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."
Memory Hierarchy
2080 · 10 marks
Explain hierarchy of different memory types along with figure. What are different types of read only memory?[10]
2079 · 10 marks
What is computer memory? Describe memory hierarchy with suitable example.[10]
Show solved answerHide answer
Computer Memory and Memory Hierarchy
What is Computer Memory?
Computer memory is a device or component in a computer system that is used to store data, instructions, and intermediate results for processing. Memory allows the CPU to access and retrieve information quickly during the execution of programs.
Memory can be broadly classified into:
- Primary Memory (Main Memory): Directly accessible by the CPU (e.g., RAM, ROM, Cache)
- Secondary Memory (Auxiliary Storage): Used for permanent storage (e.g., Hard Disk, SSD, Optical Disk)
The CPU uses registers to store data and instructions during processing, and data must be brought into the CPU's registers before it can be processed. This shows that memory plays a central role in every operation a computer performs.
Memory Hierarchy
The memory hierarchy is an arrangement of different types of memory in a computer system, organized from fastest and most expensive (smallest capacity) at the top to slowest and least expensive (largest capacity) at the bottom.
The key idea behind memory hierarchy is to balance speed, cost, and capacity so that the CPU can access data as quickly as possible while keeping the overall cost of the system reasonable.
Diagram of Memory Hierarchy
___________
| Registers | <-- Fastest, Smallest, Most Expensive
|___________|
| Cache |
|_____________|
| Main Memory |
| (RAM/ROM) |
|_______________|
| Secondary Memory |
| (Hard Disk, SSD) |
|___________________|
| Tertiary Memory |
| (Optical Disk, Tape)|
|_____________________|
<-- Slowest, Largest, Least Expensive
Levels of Memory Hierarchy (Explained)
1. Registers (Level 1 - Top)
- Registers are high-speed storage areas within the CPU itself.
- They have the least storage capacity but are the fastest memory in the hierarchy.
- They store data, instructions, and intermediate results of processing.
- Registers are often referred to as the CPU's working memory.
- Examples:
- Accumulator (ACC): Stores the result of arithmetic and logic operations.
- Instruction Register (IR): Contains the current instruction most recently fetched.
- Capacity: A few bytes to a few hundred bytes
- Speed: Extremely fast (nanoseconds or less)
2. Cache Memory (Level 2)
- Cache memory is a small, high-speed memory located between the CPU and main memory.
- It stores frequently used data and instructions so the CPU does not have to repeatedly access the slower main memory.
- Cache is divided into levels: L1 Cache (inside CPU, fastest), L2 Cache, and L3 Cache (shared among cores).
- Example: When a program runs a loop repeatedly, the loop instructions are stored in cache so the CPU can access them instantly.
- Capacity: A few KB to a few MB
- Speed: Very fast
3. Main Memory / Primary Memory (Level 3)
- Main memory is the primary working memory of the computer, directly accessible by the CPU.
- It includes:
- RAM (Random Access Memory): Volatile memory that stores currently running programs and data. Data is lost when power is turned off.
- ROM (Read Only Memory): Non-volatile memory that stores permanent instructions like the BIOS.
- Main memory (RAM) is one of the key hardware components of a computer system.
- Example: When you open a web browser, it is loaded from the hard disk into RAM so the CPU can access it quickly.
- Capacity: A few GB (e.g., 4 GB, 8 GB, 16 GB)
- Speed: Fast, but slower than cache
4. Secondary Memory (Level 4)
- Secondary memory provides permanent (non-volatile) storage for data and programs.
- It is much larger in capacity than primary memory but much slower to access.
- The CPU cannot directly access secondary memory; data must first be transferred to main memory.
- Examples: Hard Disk Drive (HDD), Solid State Drive (SSD), USB Flash Drive
- The hard disk is a block device that transfers data as blocks.
- Capacity: Hundreds of GB to several TB
- Speed: Slower than RAM
5. Tertiary / Offline Memory (Level 5 - Bottom)
- This is the lowest level of the memory hierarchy, used for backup and archival purposes.
- It is the cheapest and largest in capacity but the slowest to access.
- Examples: Optical Disks (CD, DVD, Blu-ray), Magnetic Tapes
- Capacity: Can range from GB to PB (in tape libraries)
- Speed: Very slow
Summary Table
| Memory Level | Example | Speed | Capacity | Cost |
|---|---|---|---|---|
| Registers | ACC, IR | Fastest | Bytes | Highest |
| Cache | L1, L2, L3 Cache | Very Fast | KB - MB | Very High |
| Main Memory | RAM, ROM | Fast | GB | Moderate |
| Secondary Memory | HDD, SSD | Slow | GB - TB | Low |
| Tertiary Memory | CD, Tape | Slowest | TB - PB | Lowest |
Why is Memory Hierarchy Important?
- Speed: The CPU can access data from registers and cache almost instantly, reducing waiting time.
- Cost Efficiency: Expensive fast memory (registers, cache) is used in small amounts; cheap slow memory (hard disk) is used in large amounts.
- Performance: Frequently used data is kept in higher levels (cache/registers), improving overall system performance.
- Example: When you run a calculation, the numbers are loaded from the hard disk into RAM, then into cache, and finally into the CPU registers where the actual addition or subtraction takes place. The result is stored back in the accumulator register.
Conclusion
The memory hierarchy is a fundamental concept in computer architecture that balances the competing demands of speed, cost, and capacity. By organizing storage into registers, cache, main memory, secondary memory, and tertiary memory, a computer system can give the CPU the illusion of large, fast, and inexpensive memory all at once, which is essential for efficient program execution.
2077 · 5 marks
Define memory hierarchy. Explain different types of ROM in detail. [5]
Primary Memory
2077 · 5 marks
What is primary memory? Compare primary memory with secondary memory. [5]
Magnetic Tape
2074 · 5 marks
How many numbers of bits are equivalent 1 Kilobyte? Discuss the working mechanism of magnetic tape. [5]
Make Unit 3 stick
Practice CSC114 with flashcards & quizzes