Hardware Secrets
Home | Camera | Case | CE | Cooling | CPU | Input | Memory | Mobile | Motherboard | Networking | Power | Storage | Video | Other
Content
Articles
First Look
Gabriel's Blog
News
Reviews
Tutorials
Main Menu
About Us
Awarded Products
Compare Prices
Datasheets
Dictionary
Download
Drivers
Forums
Links
Manufacturer Finder
Newsletter
On The Web
RSS Feed
Test Your Skills
Twitter
Newsletter
Subscribe today!
Search




Recommended
The Winn L. Rosch Hardware Bible, 6th Edition (2 Vol. Set)
The Winn L. Rosch Hardware Bible, 6th Edition (2 Vol. Set), by Winn L Rosch (Que), starting at $2.32
Home » CPU
How The Memory Cache Works
Author: Gabriel Torres
Type: Tutorials Last Updated: September 12, 2007
Page: 6 of 9
$ Check REAL-TIME pricing for Intel Celeron E1500 Socket 775 65mm Dual-Core Processor with 2.2GHz 800MHz FSB 512KB L2 Cache Model BX80557E1500 Retail Box Free Ground Shipping $.
Directron: $49.99 Newegg: $49.99
CircuitCity: $49.99 CDW: $62.99

How It Works

Here is how the memory cache works. The CPU fetch unit looks for the next instruction to be executed in the L1 instruction cache. If it isn’t there, it will look for it on the L2 cache. Then, if it is not there, it will have to go to the RAM memory to fetch the instruction.

We call a “hit” when the CPU loads a required instruction or data from the cache, and we call a “miss” if the required instruction or data isn’t there and the CPU needs to access the system RAM memory directly.

Of course when you turn your PC on the caches are empty, so accessing the RAM memory is required – this is an inevitable cache miss. But after the first instruction is loaded, the show begins.

When the CPU loads an instruction from a certain memory position, a circuit called memory cache controller loads into the memory cache a small block of data below the current position that the CPU has just loaded. Since usually programs flow in a sequential way, the next memory position the CPU will request will probably be the position immediately below the memory position that it has just loaded. Since the memory cache controller already loaded some data below the first memory position read by the CPU, the next data will probably be inside the memory cache, so the CPU doesn’t need to go outside to grab the data: it is already loaded inside in the memory cache embedded in the CPU, which it can access at its internal clock rate.

This amount of data is called line and it is usually 64 bytes long (more on that on the next page).

Besides loading this small amount of data, the memory controller is always trying to guess what the CPU will ask next. A circuit called prefetcher, for example, loads more data located after these first 64 bytes from RAM into the memory cache. If the program continues to load instructions and data from memory positions in a sequential way, the instructions and data that the CPU will ask next will be already loaded into the memory cache.

So we can summarize how the memory cache works as:

1. The CPU asks for instruction/data stored in address “a”.

2. Since the contents from address “a” aren’t inside the memory cache, the CPU has to fetch it directly from RAM.

3. The cache controller loads a line (typically 64 bytes) starting at address “a” into the memory cache. This is more data than the CPU requested, so if the program continues to run sequentially (i.e. asks for address a+1) the next instruction/data the CPU will ask will be already loaded in the memory cache.

4. A circuit called prefetcher loads more data located after this line, i.e. starts loading the contents from address a+64 on into the cache. To give you a real example, Pentium 4 CPUs have a 256-byte prefetcher, so it loads the next 256 bytes after the line already loaded into the cache.

If programs always run sequentially the CPU would never need to fetch data directly from the RAM memory – except to load the very first instruction – as the instructions and data required by the CPU would always be inside the memory cache before the CPU would ask for them.

However programs do not run like this, from time to time they jump from one memory position to another. The main challenge of the cache controller is trying to guess what address the CPU will jump, loading the content of this address into the memory cache before the CPU asks for it in order to avoid the CPU having to go to the RAM memory, what slows the system down. This task is called branch predicting and all modern CPUs have this feature.

Modern CPUs have a hit rate of at least 80%, meaning that at least 80% of the time the CPU isn’t accessing the RAM memory directly, but the memory cache instead.

Pages (9): « 1 2 3 4 5 [6] 7 8 9 »
Print Version | Send to Friend | | Bookmark Article | Comments (0)

Related Content
  • Penryn Core New Features
  • nVidia Tesla Technology
  • Inside Intel Nehalem Microarchitecture
  • Core 2 Duo, Core 2 Quad, Phenom X3 and Phenom X4: Which One is the Best USD 200 CPU?
  • Everything You Need to Know About the CPU C-States Power Saving Modes

  • Recommended Deal.
    Phenom II Black CPU Processor Edition AM3 965 3AMD Phenom II X4 965 Black Edition Deneb 3.4GHz 4 x 512KB L2 Cache 6MB L3 Socket AM3 140W Quad-Core Processor - Retail HDZ965FBGIBOX


    Newegg: $195.99 CircuitCity: $209.99
    Directron: $209.99 CDW: $249.99

    RSSLatest News
    Spire Announces CoolNess Laptop Cooler
    November 6, 2009 - 3:07 PM PST
    Mushkin Launches Memories with Copper-made Heatsink
    November 5, 2009 - 3:49 PM PST
    Super Talent Launches USB 3.0 Flash Memories
    November 5, 2009 - 3:47 PM PST
    VIA Announces Nano 3000 Processor Series
    November 5, 2009 - 3:42 PM PST
    Sapphire Announces Vapor-X HD 5870 and HD 5750 Video Cards
    November 5, 2009 - 3:38 PM PST
    Gelid Unveils Tranquillo CPU Cooler
    November 5, 2009 - 3:36 PM PST
    Noctua Intros NH-D14 Premium CPU Cooler
    November 3, 2009 - 8:14 PM PST
    Transcend Unveils DDR3-1333 Memory Kits
    November 3, 2009 - 7:57 PM PST
    EVGA Launches GeForce GTX 275 CO-OP PhysX Edition
    November 3, 2009 - 7:51 PM PST
    Akasa Launches Freedom Xone Mid-tower Case
    November 2, 2009 - 6:05 PM PST
    .:: More News ::.

    RSSLatest Content
    SilverStone Grandia GD04 Case Review
    Can We Trust the 80 Plus Certification?
    NZXT Gamma Case Review
    Patriot Box Office Media Player Review
    ASUS U-75HA 750 W Power Supply Review
    MSI P55-GD80 Motherboard
    Thermaltake Element V Case Review
    Nokia 7705 Twist Cell Phone Review
    Cooler Master Hyper TX3 CPU Cooler Review
    Some Pictures from Our Office
    Antec Two Hundred Case Review
    Corsair TX950W Power Supply Review
    XFX Radeon HD 5770 Video Card Review
    XFX Radeon HD 5750 Video Card Review
    Scythe Big Shuriken CPU Cooler Review

    Our Most Popular Articles
    Maximum CPU Temperature
    1,070,627 views
    How to Find Out Your Motherboard Manufacturer and Model
    694,958 views
    nVidia Chips Comparison Table
    671,317 views
    Connecting Two PCs Using a USB-USB Cable
    585,678 views
    How To Correctly Apply Thermal Grease
    555,845 views
    AMD ATI Chips Comparison Table
    554,031 views
    ATI Radeon X1300 Pro Review
    485,769 views
    ATI Radeon X1600 XT Review
    474,817 views
    How To Perform a BIOS Upgrade
    389,277 views
    Sempron vs. Athlon XP
    336,520 views

    Latest Threads in Our Forums
    Is it a vga problem or motherboard has shocked?
    by ftomsuk
    Patriot Box Office Media Player Review
    by cchjde
    Is it possible LCD Monitor leaked by itself ?
    by delta32
    Suddenly death syndrome and pendrives
    by Desert Fox
    better cpu cooler?
    by sam_wade07
    Video Transfer camcorder to PC
    by fjs559
    Spire Announces CoolNess Laptop Cooler
    by Hardware Secrets Team
    Can We Trust the 80 Plus Certification?
    by Merman
    SilverStone Grandia GD04 Case Review
    by Olle P
    Understanding Over Current Protection
    by Olle P
    .:: Visit Our Forums ::.


    © 2004-9, Hardware Secrets, LLC. All rights reserved.
    Advertising | Legal Information | Privacy Policy
    All times are Pacific Standard Time (PST, GMT -08:00)