COA-4th chapter

Memory Hierarchy in Computer Systems

  • Definition: A structured organization of different memory types in layers based on speed, size, and cost.

  • Purpose: Optimizes performance by balancing access speed with cost and storage capacity.

Levels of Memory

  1. Registers (Level 1)

    • Speed: Fastest

    • Size: Small (in bytes)

    • Cost: Expensive

    • Function: Store data and instructions for immediate processing.

  2. Cache Memory (Level 2)

    • Speed: Very fast (slower than registers, faster than main memory)

    • Size: Small (1-16MB)

    • Cost: Expensive

    • Function: Stores frequently accessed data to reduce access time from slower memory levels; divided into L1, L2, L3.

  3. Main Memory (Level 3)

    • Speed: Slower than cache memory

    • Size: Larger (4GB-64GB)

    • Cost: Moderate

    • Function: Holds active data and programs being used.

  4. Secondary Memory (Level 4)

    • Speed: Slower than RAM

    • Size: Very large (hundreds of GB to multiple TB)

    • Cost: Relatively cheap

    • Function: Stores data persistently, even when powered off.

Improvements to System Performance

  • Fast Data Access: Reduces time to retrieve data by storing frequently accessed items in faster memory.

  • Reduced Latency: Ascends performance by moving data closer to the CPU.

  • Cost-Effectiveness: Balances performance and affordability through a tiered system.

  • Efficient Memory Usage: Storing more frequently used data in the cache.

Trade-offs in Memory Levels

  1. Speed vs. Size: Fast memory types (registers, cache) are smaller in capacity than slower types (RAM, disk).

  2. Cost vs. Performance: Faster memory (cache) is more expensive than slower memory (HDD, DRAM).

  3. Complexity vs. Efficiency: Multiple levels introduce complexity in managing data and require algorithms for data replacement in caches.

  4. Energy Consumption: Fast memory consumes more energy; accessing data from registers and caches requires more power than secondary storage.

Role of Cache Memory in Computer Systems

  • Definition: Acts as a buffer between the main memory and CPU.

  • Purpose: Stores frequently accessed data to reduce access time from the slower main memory.

How Cache Memory Works

  1. CPU Request: CPU requests data from the main memory.

  2. Cache Check: The cache controller checks if the data is stored.

  3. Cache Hit: If found, data is retrieved from the cache.

  4. Cache Miss: If not found, data is fetched from main memory and stored in cache.

  5. Data Retrieval: CPU retrieves data from the cache.

Cache Mapping Techniques

  1. Associative Mapping: Flexible, stores both address and data; avoids index collision.

  2. Direct Mapping: Simpler, divides memory address into index and tag fields; can lead to collisions.

  3. Set-Associative Mapping: Combines features of both mappings, allowing multiple addresses to map to the same index.

Input/Output (I/O) Transfer Modes

  1. Programmed I/O: Data transfers initiated by instructions in the program, requiring CPU to monitor interfaces.

    • Advantage: Simplicity in implementation.

    • Disadvantage: CPU wait times can degrade performance.

  2. Interrupt-Driven I/O: Device generates an interrupt request when ready for data transfer.

    • Advantage: CPU doesn't wait and can perform other tasks.

    • Disadvantage: Overhead of handling interrupts.

  3. Direct Memory Access (DMA): Allows devices to transfer data to memory directly without CPU intervention.

    • Advantage: Frees up CPU for other tasks, enhances transfer speed.

    • Disadvantage: More complex hardware requirements.

Asynchronous vs Synchronous Data Transfer

  • Asynchronous Data Transfer: Data transfers occur without synchronized clock signals; uses start/stop bits for signaling.

    • Advantages: Flexibility in transfer timing.

    • Disadvantages: Slower transfer speeds compared to synchronous transfers.

  • Synchronous Data Transfer: Data sent in a continuous stream synchronized by clock signals.

    • Advantages: Higher data transfer rates, precise timing.

    • Disadvantages: Complexity in maintaining clock synchronization.

Mechanisms for Ensuring Data Integrity in Asynchronous Communication

  1. Parity Bits: Detect errors in transmission.

  2. Start and Stop Bits: Indicate the beginning and end of data transmission.

  3. Checksums: Verify the integrity of data.

  4. Error-Correcting Codes: Such as Hamming codes, detect and correct errors.