Geeks Talk

Prepare for your Next Interview


Welcome to the Geeks Talk forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community you will have access to post topics, communicate privately with other members (PM), respond to polls, upload content and access many other special features. Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact contact us.

Cache Hit Ratio

This is a discussion on Cache Hit Ratio within the Windows forums, part of the Operating Systems category; Hi; I have to find the hit ratio for the following 9 logical addresses supported by TLB and using FIFO. My Addresses are: 9-8-4-5-9-6-4-7-5 and I don't have the foggiest ...

Go Back   Geeks Talk > Operating Systems > Windows
Register Blogs FAQ Tag Cloud Calendar Mark Forums Read

Windows Windows related issues and problesm.

Reply

 

LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 10-18-2008
Junior Member
 
Join Date: Oct 2008
Location: Canada
Posts: 7
Thanks: 2
Thanked 0 Times in 0 Posts
pandie2008 is on a distinguished road
Cache Hit Ratio

Hi;

I have to find the hit ratio for the following 9 logical addresses supported by TLB and using FIFO. My Addresses are: 9-8-4-5-9-6-4-7-5 and I don't have the foggiest idea where to start! Help! Thanks
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 10-19-2008
Contributing Member
 
Join Date: Dec 2007
Posts: 48
Thanks: 1
Thanked 8 Times in 7 Posts
sk_seeker is on a distinguished road
Re: Cache Hit Ratio

Quote:
Originally Posted by pandie2008 View Post
Hi;

I have to find the hit ratio for the following 9 logical addresses supported by TLB and using FIFO. My Addresses are: 9-8-4-5-9-6-4-7-5 and I don't have the foggiest idea where to start! Help! Thanks
You haven't the foggiest idea huh?? Lets try and dispel the fog bit by bit.

What is a cache??
A mechanism where we maintain a copy of the data in a faster area as compared to the real data that may be in a slower area. For example, hardware cache memory. Cache memory is faster than main memory: so if we maintain a copy of the data in cache, then the next time the same data is accessed, then if the copy of that data is in cache, then there is no need to go all the way to memory to fetch the data. So, cache speeds up the access to data in main memory.

What is a Cache hit??
When the CPU generates a load instruction, the cache is first checked to see if the data being loaded is already in the cache. How did it get into the cache?? From a prior access to the same data, which went all the way to memory and stored a copy in the cache. When the data is found in the cache itself, we call this as a Cache hit. If you do not find it in the cache, it is called a cache miss. On a cache miss, data has to be fetched from memory itself.

What is a TLB??
TLB stands for Translation Lookaside Buffer. In Virtual memory systems, the cpu generates virtual memory addresses. But, the data is stored in actual physical memory i.e. we need to place a physical memory address on the memory bus to fetch the data from the memory circuitry. So, a special table is maintained by the operating system called the Page table. This table contains a mapping between the virtual addresses and physical addresses. So, everytime a cpu generates a virtual address, the operating system page table has to be looked up to find the corresponding physical address. To speed this up, there is hardware support called the TLB. The TLB is a high speed cache of the page table i.e. contains recently accessed virtual to physical translations.

What is a TLB hit ratio??
Just like the cache hit, a TLB hit is the no of times a virtual-to-physical address translation was already found in the TLB, instead of going all the way to the page table which is located in slower physical memory.

TLB hit ratio is nothing but the ratio of TLB hits/Total no of queries into TLB. For example, if I asked the TLB 10 times for virtual-to-physical mappings, and found the mapping 4 times, then my hit ratio is 4/10 i.e. 40%.

In your example, 984506475 is the logical/virtual address sequence. Assuming an infinite size TLB, how many tlb hits will we have?? 9, 4, 5 are accessed more than once. So, hit ration is 3/9 = 33%.

But, the question also mentions that the TLB is a FIFO i.e. this means that the TLB size is limited. So, there is missing info in the question. Lets assume that the TLB size is 4. So, here is what happens when each new address is accessed:
9
89
489
5489
0548
6054
4605
7460
5746

If you notice, the above is a FIFO simulation. So, how many hits will we have?? None. So, hit ratio is 0%.

Hope that helps.
Reply With Quote
The Following User Says Thank You to sk_seeker For This Useful Post:
  #3 (permalink)  
Old 10-23-2008
Junior Member
 
Join Date: Oct 2008
Location: Canada
Posts: 7
Thanks: 2
Thanked 0 Times in 0 Posts
pandie2008 is on a distinguished road
Re: Cache Hit Ratio

Thanks very much!!! I am also been introduced to LRU and if I think about what you explained the same sequence using LRU would show my hit ratio of 100% correct?
Reply With Quote
  #4 (permalink)  
Old 10-23-2008
Contributing Member
 
Join Date: Dec 2007
Posts: 48
Thanks: 1
Thanked 8 Times in 7 Posts
sk_seeker is on a distinguished road
Re: Cache Hit Ratio

Quote:
Originally Posted by pandie2008 View Post
Thanks very much!!! I am also been introduced to LRU and if I think about what you explained the same sequence using LRU would show my hit ratio of 100% correct?
Not quite. Lets take the same example that you initially quoted: 984506475.

Assuming an infinite size TLB, how many tlb hits will we have?? Since an infinite TLB size implies that we never have to evict anybody, we will never have to use an LRU algorithm to choose somebody to evict. So, since 9, 4, 5 are accessed more than once, only those three accesses will have a TLB hit. Since other logical addresses are accessed only once, they will take a TLB miss each time they are accessed. So, hit ratio is still 3/9 = 33%.

But. lets assume that the TLB size is fixed at 4, and we are using an LRU algorithm to evict the oldest logical address.

984506475

9
89
489
5489
Least recently used at this point is 9. So, evict 9 and insert 0 in its place
5480
Least recently used at this point is 8. So, evict 8 and insert 6 in its place
5460
4 is accessed again, but is already in the cache. So, it is a hit, and its access time becomes more recent.
5460
Least recently used at this point is 5. So, evict 5 and insert 7 in its place.
7460
Least recently used at this point is 0. So, evict 0 and insert 5 in its place.
7465

So, the hit ratio = 1/9.
Reply With Quote
  #5 (permalink)  
Old 10-25-2008
Junior Member
 
Join Date: Oct 2008
Location: Canada
Posts: 7
Thanks: 2
Thanked 0 Times in 0 Posts
pandie2008 is on a distinguished road
Re: Cache Hit Ratio

Thank you very much. I wonder though would it make a difference if the cache is already full to start with?
Reply With Quote
  #6 (permalink)  
Old 04-16-2009
Junior Member
 
Join Date: Feb 2008
Location: dsds
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
tituxjec is on a distinguished road
Re: Cache Hit Ratio

but i think we do have a hit after 6054 for '4' in ur first example. So i think ur 1st exmple works same as LRU.
Reply With Quote
Reply

  Geeks Talk > Operating Systems > Windows

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads

Thread Thread Starter Forum Replies Last Post
How to Clear the IE Browser Cache in QTP? jyllana24 QTP 1 09-26-2008 01:52 AM
To find ratio !!! karthizen SQL 4 06-04-2008 08:16 AM
Dynamic Lookup Cache rasmi Data Warehousing 0 03-04-2008 05:50 AM
Post/Member Ratio kalayama Suggestions & Feedback 3 12-14-2006 06:02 AM
Aspect Ratio nancyphilips C and C++ 1 07-23-2006 12:30 PM


All times are GMT -4. The time now is 02:18 AM.


Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.3.1
Copyright © 2009 GeekInterview.com. All Rights Reserved