unit_4

Memory Hierarchy

  • Different types of storage with varying capacity, speed of access, and cost per bit to store.

  • No single type of storage is superior in all aspects; thus, a hierarchy of storage technologies is utilized in most computer systems.

Characteristics of Storage Types

  • Smaller capacity ➔ Faster access time & higher cost per bit stored.

  • Larger capacity ➔ Slower access time & lower cost per bit stored.

Types of Storage Devices

  • Cache Memory: Fastest access, smallest storage capacity, and highest cost.

  • Main Memory: Serves as primary storage; slower than cache.

  • Secondary Storage: Includes:

    • Online direct access (e.g., hard disk)

    • Offline direct access (e.g., magnetic tape, floppy disk)

    • Mass storage (e.g., tape library, CDs)

Virtual Memory

  • Provides users with an illusion of working with a large continuous block of memory space, while actual work occurs in primary memory.

  • Allows the use of secondary memory as if it is primary memory.

  • Addresses used are referred to as virtual addresses, while those used in main memory are called physical addresses.

Address Mapping

  • A mapping table is used to convert virtual addresses to physical addresses; stored in a portion of main memory.

Paging in Memory Management

  • Memory management technique dividing address and memory space into equal size groups (pages and blocks).

  • Example:

    • Secondary memory of 16K divided into 16 pages.

    • Main memory of 4K divided into 4 blocks.

    • Pages are read into main memory as needed; only a limited number of pages can remain in memory at once.

Page Table

  • A memory page table stored in main memory lists virtual pages and their corresponding blocks in memory, including a presence bit indicating if a page is in main memory.

Cache Memory

  • A special type of memory used to increase data processing speed between CPU and main memory.

  • Works as a mediator to store temporary data, improving access speed.

Characteristics of Cache Memory

  • Small size, also known as high-speed memory.

  • Improves data transfer rate but has a higher cost compared to main memory.

Locality of Reference

  • Refers to the tendency for memory addresses accessed to cluster in localized areas over time.

  • Types of Locality:

    • Temporal Locality: Recently accessed data is likely to be accessed again soon.

    • Spatial Locality: Data close to each other is likely to be accessed near each other.

Cache Memory Performance

  • Measured in terms of hit ratio:

    • Hit: When requested data is found in cache.

    • Miss: When requested data is not found in cache.

  • Hit Ratio Formula:[ \text{Hit Ratio} = \frac{\text{No. of Hits}}{\text{No. of Hits} + \text{No. of Misses}} ]

Mapping Processes

Types of Mapping

  1. Associative Mapping: Flexible organisation; allows any location in cache to store any memory word.

  2. Direct Mapping: Each memory address maps to one cache line, leading to potential conflicts with different data sharing the same index.

  3. Set Associative Mapping: Combines features of both; allows for multiple data words to be stored under the same index, increasing flexibility and reducing conflict.

Example of Set Associative Mapping

  • Cache can store two data words of memory under the same index address, improving efficiency and reducing cache misses.