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




Recommended Book
The Winn L. Rosch Hardware Bible (6th Edition)
By Winn L Rosch
Que
Price: $0.92

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 Core 2 Duo Retail Boxed E7200 Processor - 2.53GHz, 3MB Cache, 1066MHz FSB, 45nm Wolfdale E700 Boxed Processor $
ZipZoomfly.com: $119.00 PCNation: $138.32
Newegg.com: $119.99 Dell: $159.99
CompuVest: $129.91 CDW Corporation: $154.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
  • VIA C7-M Processor
  • Inside Pentium 4 Architecture
  • All Pentium 4 Models
  • How Chips are Manufactured
  • Intel Fab18 Factory Tour in Kiryat Gat, Israel

  • Recommended Deals
    AMD Athlon 64 3500+, 2.2 GHz (ada3500dik4b) OEM / Unboxed Processor


    CompuVest: $42.99 ZipZoomfly.com: $59.99
    Amazon: $656.90 Hpshopping: $441.99
    Jlpnetworksstore: $801.14 Zappos: $826.00
    AMD Athlon™ 64 3800 3800+, 2 GHz AMD Processor in a Box (PIB)


    Server Supply: $135.00 Amazon: $103.39
    Hpshopping: $441.99 Zappos: $826.00
    Jlpnetworksstore: $801.14
    AMD Athlon™ 64 3000+, 2.0 GHz (ada3000box) AMD Processor in a Box (PIB)


    ZipZoomfly.com: $105.00 Hpshopping: $441.99
    Amazon: $656.90 Jlpnetworksstore: $801.14
    Zappos: $826.00
    Intel Core™2 Quad Q6600, 2.40 GHz (BX80562Q6600) Boxed Processor


    CompUSA.com: $189.99 Circuit City: $279.99
    TigerDirect.com: $189.99 ZipZoomfly.com: $188.50
    Dell: $329.99

    RSSLatest News
    Patriot Launches SO-DIMM DDR3-2000
    September 5, 2008 - 7:28 AM PST
    Kingston Unveils HyperX SO-DIMM Memory Kit
    September 4, 2008 - 10:59 AM PST
    Thermaltake Launches V9 Case Series
    September 3, 2008 - 7:54 AM PST
    Sigma Launches 1,000 W Power Supply
    September 2, 2008 - 7:55 AM PST
    Intel Launches New Processors
    September 1, 2008 - 11:16 AM PST
    Scythe Launches Kaze Maru Case Fan
    September 1, 2008 - 10:24 AM PST
    Lian Li Launches Silent Force Power Supply Series
    August 29, 2008 - 9:24 AM PST
    New Thermaltake Power Supplies
    August 28, 2008 - 11:43 AM PST
    Sparkle and MSI Launch GeForce 9400 GT
    August 28, 2008 - 11:13 AM PST
    NZXT Unveils Whisper Full Tower Case
    August 28, 2008 - 10:39 AM PST
    .:: More News ::.

    RSSLatest Content
    Everything You Need to Know About the CPU C-States Power Saving Modes
    AMD ATI Chips Comparison Table
    nVidia Chips Comparison Table
    Inside Intel Nehalem Microarchitecture
    OCZ Elixir Gaming Keyboard Review
    Everything You Need to Know About The QuickPath Interconnect (QPI)
    Me and Woz
    Introduction to Wireless USB (WUSB)
    Nikon Coolpix S600 Camera Review
    IDF Fall 2008: Opening Keynote
    Thecus N5200 NAS Review
    ECS GeForce 9800 GTX+ Hydra Video Card Review
    320 GB Hard Disk Drive Round-Up
    Razer Destructor Mouse Pad Review
    Sapphire HD 4870 X2 Video Card Review

    Our Most Popular Articles
    Maximum CPU Temperature
    771,761 views
    nVidia Chips Comparison Table
    480,045 views
    AMD ATI Chips Comparison Table
    425,472 views
    ATI Radeon X1300 Pro Review
    413,770 views
    ATI Radeon X1600 XT Review
    408,538 views
    How to Find Out Your Motherboard Manufacturer and Model
    384,769 views
    Connecting Two PCs Using a USB-USB Cable
    347,530 views
    How To Correctly Apply Thermal Grease
    332,810 views
    Sempron vs. Athlon XP
    280,042 views
    Sempron 3400+ Review
    270,226 views

    Latest Threads in Our Forums
    Slipstreaming SP3
    by Gabriel Torres
    Building PC for Audio.
    by Wall'E
    What configuration is better??
    by Gabriel Torres
    Upgrading to dual core
    by Gabriel Torres
    Patriot Launches SO-DIMM DDR3-2000
    by Hardware Secrets Team
    overclocking e8400 problem
    by andybarrel
    Everything You Need to Know About the CPU C-States Power Saving Modes
    by Hardware Secrets Team
    Cooler Master Cosmos S Case Review
    by Retratserif
    Kingston Unveils HyperX SO-DIMM Memory Kit
    by Hardware Secrets Team
    New Forum: PC Doesn't Turn On
    by Gabriel Torres
    .:: Visit Our Forums ::.

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