3 Computer Memory

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.

Computer Memory: notes

Introduction

Computer memory is a physical device capable of storing information temporarily or permanently. RAM (random access memory) stores information temporarily and ROM (read only memory) stores information permanently. Memory devices use integrated circuits and are relied upon by operating systems, software and hardware alike.

Memory Representation

A bit is a single binary digit, 0 or 1, corresponding to the electrical values off or on, and is the smallest unit of data representation in a computer. A group of 8 bits is called a byte, which can represent 256 different combinations. Larger units build on the byte: a kilobyte (KB) is 1024 bytes, a megabyte (MB) is 1024 KB, a gigabyte (GB) is 1024 MB, and a terabyte (TB) is 1024 GB. A group of bytes can further be combined to form a word.

Memory Hierarchy

Memory is characterized by two key factors, capacity and access time; the lesser the access time, the faster the memory. Computers organize memory into a hierarchy designed to give the fastest possible speed together with the largest possible capacity, classified on the basis of capacity, access time and cost. Referring to computer memory usually means the internal memory, whose key features are limited storage capacity, temporary storage, fast access and high cost. Internal memory consists of registers, cache memory and primary memory, with primary memory further divided into RAM and ROM. Below internal memory sits the secondary memory, made up of magnetic disk and optical disk storage together with magnetic tape, which trades speed for far greater capacity and permanence.

CPU Registers

Registers are the fastest and most expensive memory type, located inside the CPU and directly accessible by it. Their access speed is between 1 and 2 nanoseconds, and their size is only about 200 bytes.

Cache Memory

Cache memory sits next in the hierarchy, placed between the CPU and main memory, with an access speed between 2 and 10 nanoseconds and a size that varies between 32 KB and 4 MB. It is accessed directly by the CPU, holds the data and instructions currently being worked on, and is a volatile, semiconductor based memory of limited capacity: its contents are lost when the computer is powered off.

Primary Memory

Any program or data that is to be executed must first be brought into primary memory from secondary memory. Its access speed is around 60 nanoseconds and its size ranges from 512 KB to 3 GB. Primary memory is of two kinds, RAM and ROM.

Random Access Memory (RAM) stores data and instructions while the computer is operating; the CPU interacts with RAM to fetch data and instructions for processing. RAM is volatile, losing its information when the computer is powered off, and its size is limited by its high cost, which in turn affects the speed and power of the computer. RAM is built using one of two technologies. Dynamic RAM (DRAM) is the most common memory chip, used mainly as main memory because it is small and cheap; it pairs a transistor with a capacitor to form each memory cell, with the capacitor holding a bit as a charged or discharged state. Because the capacitor's charge leaks away, DRAM must be continuously refreshed by a memory controller, which makes it slower, with access speeds ranging from 50 to 150 ns. Static RAM (SRAM) is usually used in cache memory for its high speed; it uses four to six transistors per memory cell instead of a capacitor, so it takes up more space on a chip and is more expensive than DRAM, but it needs no constant refreshing and so is faster, with access speeds from 2 to 10 nanoseconds.

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]

--- Feature Primary Memory Secondary Memory --------- Also Known As Main memory, Internal memory Auxiliary memory, Storage device Location Inside the computer (directly accessible by CPU) External to CPU (not directly accessible) Speed Very fast (RAM: ~60 ns) Much slower than primary memory Stora...

Open this answer on its own page →

Cache Memory

2081 · 5 marks

Write short notes on: a.) Cache Memory b.) IoT [5]

Cache memory is a very high-speed memory placed between the CPU and RAM (main memory) in the memory hierarchy. Feature Details ------ Speed 2 to 10 nanoseconds Size 32 KB to 4 MB Cost Very expensive Type Uses SRAM (Static RAM) Volatility Volatile (data lost on power off) 1. When the CPU needs dat...

Open this answer on its own page →

2078 · 5 marks

What is cache memory? How is it different from register? [5]

Cache memory is a high-speed temporary storage located between the CPU and the main memory (RAM) in the memory hierarchy. Its primary purpose is to reduce the average time required to access data from the main memory by storing frequently used data and instructions closer to the CPU. Key characte...

Open this answer on its own page →

2075 · 5 marks

What is the purpose of cache memory? How sequential access differs from direct access? [5]

Show solved 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:

  1. 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.

  2. 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.

  3. 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.

FeatureSequential AccessDirect Access
DefinitionData is accessed in a sequential order from start to endData can be accessed in any order, directly at any location
OrderMust read all preceding records before reaching the desired oneCan jump directly to the required record
SpeedSlower for retrieving a specific recordFaster for retrieving a specific record
ExampleReading a tape from beginningReading a specific block on a hard disk
FlexibilityLess flexibleMore 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.
Open this answer on its own page →

0 · 5 marks

What is the purpose of cache memory? How sequential access differs from direct access? [5]

Show solved 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:

  1. 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.

  2. 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.

  3. 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.

  4. 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

FeatureSequential AccessDirect Access
DefinitionData is accessed in a sequential order from start to endData can be accessed in any order, directly at any location
Order of AccessMust go through all preceding records to reach a target recordCan jump directly to the required record
SpeedSlower, especially for records near the endFaster, as any record is reachable immediately
ExampleMagnetic tapeHard disk, RAM
Use CaseReading a file from beginning to endSearching 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."

Open this answer on its own page →

Memory Hierarchy

2080 · 10 marks

Explain hierarchy of different memory types along with figure. What are different types of read only memory?[10]

Computer memory is a physical device capable of storing information temporarily or permanently. RAM stores information temporarily while ROM stores information permanently. Memory devices utilize integrated circuits and are used by operating systems, software, and hardware. --- The memory hierarc...

Open this answer on its own page →

2079 · 10 marks

What is computer memory? Describe memory hierarchy with suitable example.[10]

Show solved 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 LevelExampleSpeedCapacityCost
RegistersACC, IRFastestBytesHighest
CacheL1, L2, L3 CacheVery FastKB - MBVery High
Main MemoryRAM, ROMFastGBModerate
Secondary MemoryHDD, SSDSlowGB - TBLow
Tertiary MemoryCD, TapeSlowestTB - PBLowest

Why is Memory Hierarchy Important?

  1. Speed: The CPU can access data from registers and cache almost instantly, reducing waiting time.
  2. Cost Efficiency: Expensive fast memory (registers, cache) is used in small amounts; cheap slow memory (hard disk) is used in large amounts.
  3. Performance: Frequently used data is kept in higher levels (cache/registers), improving overall system performance.
  4. 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.

Open this answer on its own page →

2077 · 5 marks

Define memory hierarchy. Explain different types of ROM in detail. [5]

--- Memory hierarchy is the arrangement of different types of computer memory in a layered structure based on their speed, cost, and storage capacity. As we move up the hierarchy, memory becomes faster and more expensive but has smaller capacity. As we move down, memory becomes slower and cheaper...

Open this answer on its own page →

Primary Memory

2077 · 5 marks

What is primary memory? Compare primary memory with secondary memory. [5]

Primary memory (also called main memory or internal memory) is the memory that is directly accessible by the CPU and holds the data and instructions that are currently being processed. It is a volatile memory, meaning its contents are lost when the power is switched off. It is made of semiconduct...

Open this answer on its own page →

Magnetic Tape

2074 · 5 marks

How many numbers of bits are equivalent 1 Kilobyte? Discuss the working mechanism of magnetic tape. [5]

  • Unit to convert: 1 Kilobyte - Standard relations: 1 Byte = 8 bits, 1 Kilobyte = 1024 Bytes --- Standard unit relations: Unit Relation ---------------- 1 Bit Smallest unit (0 or 1) 1 Byte = 8 bits 1 Kilobyte (KB) = 1024 Bytes Calculation: $$1 \text{ Kilobyte} = 1024 \text{ Bytes}$$ $$1 \text{ By...
Open this answer on its own page →