SlideShare a Scribd company logo
1 of 20
CACHE
SIMULATOR PRESENTED BY -
SURAJ KUMAR SAINI
SANCHIT JAIN
RAHUL RAWAT
NARESH BILONIYA
1
OVERVIEW
• Cache Memory
• Types of cache
• CACHE SIMULATOR
• Cache Mapping
• CACHE HIT/MISS
• WRITE POLICY
• REPLACEMENT ALGORITHM
2
CACHE MEMORY
• A cache is a hardware or software component that stores data so that for future
requests that data can be served faster.
• Cache memory is used in order to achieve higher performance of CPU by allowing
the CPU to access data at faster speed.
3
TYPES OF CACHE
• L1 , L2 , L3 cache are built to decrease the time taken to access data by the processor
.This time taken is called latency.
• L1 cache(2KB-64KB) : it is smaller in size and the instructions are first searched in it.
• L2 cache(256KB-512KB) : it is comparatively larger in size and the instructions not found
in the L1 are searched here.
• L3 cache(1MB – 8MB) : Size is largest among all cache and instructions not found in L2
are searched here.
4
CACHE SIMULATOR
 This project simulates a write through or a write back direct mapped
cache in C.
 It calculates the number of memory writes and memory reads for a
memory access pattern provided as a file.
 It computes the number of cache hits and misses as well as the
number of main memory reads and writes.
5
Cache mapping divided in three category:
• Direct Mapped
• Associative
• Set Associative
CACHE MAPPING6
The direct mapping technique is simple and inexpensive to implement.
When the CPU wants to access data from memory, it places a address.
The index field of CPU address is used to access address.
The tag field of CPU address is compared with the associated tag in the word read
from the cache.
If the tag-bits of CPU address is matched with the tag-bits of cache, then there is a
hit and the required data word is read from cache.
7 DIRECT MAPPED
DIRECT MAPPING8
ASSOCIATIVE CACHE
• This mapping scheme attempts to improve cache utilization.
• In associative cache mapping, the data from any location in RAM
can be stored in any location in cache
• When the processor wants an address, all tag fields in the cache as
checked to determine if the data is already in the cache
• Each tag line requires circuitry to compare the desired address with
the tag field
• All tag fields are checked in parallel
9
SET ASSOCIATIVE MAPPING
• Set associative mapping is a mixture of direct and associative
mapping
• The cache lines are grouped into sets
• The number of lines in a set can vary from 2 to 16
• A portion of the address is used to specify which set will hold
an address
• The data can be stored in any of the lines in the set
10
CACHE HIT/MISS
Cache Hit
• A cache hit is a state in which data
requested for processing by a
component or application is found in
the cache memory.
• It is a faster means of delivering data
to the processor, as the cache already
contains the requested data.
Cache Miss
• Cache miss is a state where the data
requested for processing by a
component or application is not found in
the cache memory.
• It causes execution delays by requiring
the program or application to fetch the
data from other cache levels or the main
memory.
11
WRITE POLICY
• The cache's write policy determines how it handles writes to memory locations
that are currently being held in cache.
• These two popular cache write policies (schemes) are:
1. Write-Through
2. Write-Back
12
Write-Back Cache
• When the system writes to a memory location that is currently held in cache,
it only writes the new information to the appropriate cache line. When the
cache line is eventually needed for some other memory address, the changed
data is "written back" to system memory.
• This type of cache provides better performance than a write-through cache,
because it saves on (time-consuming) write cycles to memory.
13
WRITE-THROUGH CACHE
• When the system writes to a memory location that is currently held in
cache, it writes the new information both to the appropriate cache line
and the memory location itself at the same time.
• This type of caching provides worse performance than write-back, but is
simpler to implement and has the advantage of internal consistency,
because the cache is never out of sync with the memory the way it is with
a write-back cache
14
REPLACEMENT ALGORITHM
• Replacement algorithms are used when there are no available space in a cache in which to place a
data.
• In this cache simulator, we have used FIFO and LRU Replacement Algorithms.
• Factors to consider
1. Read/Write Balance. (What percentage of accesses are reads vs writes)
2. Amount of cache.
3. Type of media behind the cache. (Are they slow SATA drives or fast SSD drives?)
4. Hits vs Misses. (How often are things rewritten or reread?)
5. Average access size (This goes into choose the page size)
6. How expensive are reads and writes.
15
FIRST IN FIRST OUT
• The FIFO algorithm selects for replacement
the item that has been in the cache from
the longest time.
• Using this algorithm the cache behaves in
the same way as a FIFO queue. The cache
evicts the first block accessed first without
any regard to how often or how many times
it was accessed before.
16
LEAST RECENTLY USED
• The LRU caching scheme is used to remove
the least recently used item when the
cache is full and a new item is referenced
which is not there in cache.
• This algorithm requires keeping track of
what was used when, which is expensive if
one wants to make sure the algorithm
always discards the least recently used
item.
17
IMPLEMENTATION IN SIMULATOR
• FIFO using Queue: A FIFO cache is one that uses queuing logic for its backing store,
expunging the elements at the front of the queue when a predetermined threshold is
exceeded. For implementing queue using array, we keep track of two indices, front and
rear. We enqueue an item at the rear and dequeue an item from front.
• LRU using Doubly Linked List : To implement LRU keep the doubly-linked list in each
set sorted by the order in which the cache lines were referenced. This can be done by
removing a cache line from the linked list each time you reference it, and inserting it
back into the linked list at the head. In this case, you should always evict the cache line
at the tail of the list .
18
SIMULATOR OUTPUT
• Total Hit Rate: The percentage of memory cache (i.e. lines in the trace file)
that were hits. This number should be truncated to 4 decimal places of
precision.
• Total Run Time: The total run time of the program, assuming that the last
memory access was the last instruction of the program. The unit for this
should be cycles.
• Average Memory Access Latency: The average number of cycles needed to
complete a memory access. This number should be to 4 decimal places of
precision.
19
THANK YOU
20

More Related Content

What's hot

9 virtual memory management
9 virtual memory management9 virtual memory management
9 virtual memory managementDr. Loganathan R
 
Multiprocessor Architecture (Advanced computer architecture)
Multiprocessor Architecture  (Advanced computer architecture)Multiprocessor Architecture  (Advanced computer architecture)
Multiprocessor Architecture (Advanced computer architecture)vani261
 
page replacement.pptx
page replacement.pptxpage replacement.pptx
page replacement.pptxhomipeh
 
Cryptographic Algorithms: DES and RSA
Cryptographic Algorithms: DES and RSACryptographic Algorithms: DES and RSA
Cryptographic Algorithms: DES and RSAaritraranjan
 
Paging and Segmentation
Paging and SegmentationPaging and Segmentation
Paging and SegmentationMadhur Gupta
 
Operating system memory management
Operating system memory managementOperating system memory management
Operating system memory managementrprajat007
 
Cipher techniques
Cipher techniquesCipher techniques
Cipher techniquesMohd Arif
 
Encryption And Decryption Using AES Algorithm
Encryption And Decryption Using AES AlgorithmEncryption And Decryption Using AES Algorithm
Encryption And Decryption Using AES AlgorithmAhmed Raza Shaikh
 
Data hiding - Steganography
Data hiding - SteganographyData hiding - Steganography
Data hiding - SteganographyMohamed Talaat
 
Steganography presentation
Steganography presentationSteganography presentation
Steganography presentationAshwin Prasad
 
Lecture 4 principles of parallel algorithm design updated
Lecture 4   principles of parallel algorithm design updatedLecture 4   principles of parallel algorithm design updated
Lecture 4 principles of parallel algorithm design updatedVajira Thambawita
 
Cosequential processing and the sorting of large files
Cosequential processing and the sorting of large filesCosequential processing and the sorting of large files
Cosequential processing and the sorting of large filesDevyani Vaidya
 
Os Swapping, Paging, Segmentation and Virtual Memory
Os Swapping, Paging, Segmentation and Virtual MemoryOs Swapping, Paging, Segmentation and Virtual Memory
Os Swapping, Paging, Segmentation and Virtual Memorysgpraju
 
End to End Encryption in 10 minutes -
End to End Encryption in 10 minutes - End to End Encryption in 10 minutes -
End to End Encryption in 10 minutes - Thomas Seropian
 

What's hot (20)

9 virtual memory management
9 virtual memory management9 virtual memory management
9 virtual memory management
 
Multiprocessor Architecture (Advanced computer architecture)
Multiprocessor Architecture  (Advanced computer architecture)Multiprocessor Architecture  (Advanced computer architecture)
Multiprocessor Architecture (Advanced computer architecture)
 
page replacement.pptx
page replacement.pptxpage replacement.pptx
page replacement.pptx
 
Cryptographic Algorithms: DES and RSA
Cryptographic Algorithms: DES and RSACryptographic Algorithms: DES and RSA
Cryptographic Algorithms: DES and RSA
 
Paging and Segmentation
Paging and SegmentationPaging and Segmentation
Paging and Segmentation
 
Operating system memory management
Operating system memory managementOperating system memory management
Operating system memory management
 
Cipher techniques
Cipher techniquesCipher techniques
Cipher techniques
 
Data compression
Data compressionData compression
Data compression
 
Cryptography
CryptographyCryptography
Cryptography
 
Encryption And Decryption Using AES Algorithm
Encryption And Decryption Using AES AlgorithmEncryption And Decryption Using AES Algorithm
Encryption And Decryption Using AES Algorithm
 
Data hiding - Steganography
Data hiding - SteganographyData hiding - Steganography
Data hiding - Steganography
 
Steganography presentation
Steganography presentationSteganography presentation
Steganography presentation
 
Lecture 4 principles of parallel algorithm design updated
Lecture 4   principles of parallel algorithm design updatedLecture 4   principles of parallel algorithm design updated
Lecture 4 principles of parallel algorithm design updated
 
Passwords presentation
Passwords presentationPasswords presentation
Passwords presentation
 
Cosequential processing and the sorting of large files
Cosequential processing and the sorting of large filesCosequential processing and the sorting of large files
Cosequential processing and the sorting of large files
 
Os Swapping, Paging, Segmentation and Virtual Memory
Os Swapping, Paging, Segmentation and Virtual MemoryOs Swapping, Paging, Segmentation and Virtual Memory
Os Swapping, Paging, Segmentation and Virtual Memory
 
Memory Management
Memory ManagementMemory Management
Memory Management
 
Multimedia
MultimediaMultimedia
Multimedia
 
Memory hierarchy
Memory hierarchyMemory hierarchy
Memory hierarchy
 
End to End Encryption in 10 minutes -
End to End Encryption in 10 minutes - End to End Encryption in 10 minutes -
End to End Encryption in 10 minutes -
 

Similar to CACHE SIMULATOR WITH FIFO AND LRU REPLACEMENT

cache memory and types of cache memory,
cache memory  and types of cache memory,cache memory  and types of cache memory,
cache memory and types of cache memory,ashima967262
 
Computer architecture for HNDIT
Computer architecture for HNDITComputer architecture for HNDIT
Computer architecture for HNDITtjunicornfx
 
Cache memory and cache
Cache memory and cacheCache memory and cache
Cache memory and cacheVISHAL DONGA
 
Elements of cache design
Elements of cache designElements of cache design
Elements of cache designRohail Butt
 
cachememory-210517060741 (1).pdf
cachememory-210517060741 (1).pdfcachememory-210517060741 (1).pdf
cachememory-210517060741 (1).pdfOmGadekar2
 
Introduction to memory management
Introduction to memory managementIntroduction to memory management
Introduction to memory managementSweety Singhal
 
Cache memoy designed by Mohd Tariq
Cache memoy designed by Mohd TariqCache memoy designed by Mohd Tariq
Cache memoy designed by Mohd TariqMohd Tariq
 
Memory organization.pptx
Memory organization.pptxMemory organization.pptx
Memory organization.pptxRamanRay105
 
computer architecture and organisation
computer architecture and organisationcomputer architecture and organisation
computer architecture and organisationRamjiChaurasiya
 
Computer organization memory hierarchy
Computer organization memory hierarchyComputer organization memory hierarchy
Computer organization memory hierarchyAJAL A J
 
Computer Organisation and Architecture (COA)
Computer Organisation and Architecture (COA)Computer Organisation and Architecture (COA)
Computer Organisation and Architecture (COA)SwapnitaSrivastava1
 
Overview of the ehcache
Overview of the ehcacheOverview of the ehcache
Overview of the ehcacheHyeonSeok Choi
 

Similar to CACHE SIMULATOR WITH FIFO AND LRU REPLACEMENT (20)

Cache Memory.pptx
Cache Memory.pptxCache Memory.pptx
Cache Memory.pptx
 
Cache Memory.pptx
Cache Memory.pptxCache Memory.pptx
Cache Memory.pptx
 
Computer architecture
Computer architectureComputer architecture
Computer architecture
 
cache memory and types of cache memory,
cache memory  and types of cache memory,cache memory  and types of cache memory,
cache memory and types of cache memory,
 
Computer architecture for HNDIT
Computer architecture for HNDITComputer architecture for HNDIT
Computer architecture for HNDIT
 
Cache memory and cache
Cache memory and cacheCache memory and cache
Cache memory and cache
 
Elements of cache design
Elements of cache designElements of cache design
Elements of cache design
 
Cache Memory
Cache MemoryCache Memory
Cache Memory
 
cachememory-210517060741 (1).pdf
cachememory-210517060741 (1).pdfcachememory-210517060741 (1).pdf
cachememory-210517060741 (1).pdf
 
COA (Unit_4.pptx)
COA (Unit_4.pptx)COA (Unit_4.pptx)
COA (Unit_4.pptx)
 
Introduction to memory management
Introduction to memory managementIntroduction to memory management
Introduction to memory management
 
Cache memoy designed by Mohd Tariq
Cache memoy designed by Mohd TariqCache memoy designed by Mohd Tariq
Cache memoy designed by Mohd Tariq
 
Cache memory
Cache memoryCache memory
Cache memory
 
Memory organization.pptx
Memory organization.pptxMemory organization.pptx
Memory organization.pptx
 
Cache memory
Cache memoryCache memory
Cache memory
 
computer architecture and organisation
computer architecture and organisationcomputer architecture and organisation
computer architecture and organisation
 
Computer organization memory hierarchy
Computer organization memory hierarchyComputer organization memory hierarchy
Computer organization memory hierarchy
 
Computer Organisation and Architecture (COA)
Computer Organisation and Architecture (COA)Computer Organisation and Architecture (COA)
Computer Organisation and Architecture (COA)
 
Overview of the ehcache
Overview of the ehcacheOverview of the ehcache
Overview of the ehcache
 
cache memory
 cache memory cache memory
cache memory
 

Recently uploaded

Russian Call Girls Kolkata Chhaya 🤌 8250192130 🚀 Vip Call Girls Kolkata
Russian Call Girls Kolkata Chhaya 🤌  8250192130 🚀 Vip Call Girls KolkataRussian Call Girls Kolkata Chhaya 🤌  8250192130 🚀 Vip Call Girls Kolkata
Russian Call Girls Kolkata Chhaya 🤌 8250192130 🚀 Vip Call Girls Kolkataanamikaraghav4
 
Call Girls in Dwarka Sub City 💯Call Us 🔝8264348440🔝
Call Girls in Dwarka Sub City 💯Call Us 🔝8264348440🔝Call Girls in Dwarka Sub City 💯Call Us 🔝8264348440🔝
Call Girls in Dwarka Sub City 💯Call Us 🔝8264348440🔝soniya singh
 
Call Girls Delhi {Rs-10000 Laxmi Nagar] 9711199012 Whats Up Number
Call Girls Delhi {Rs-10000 Laxmi Nagar] 9711199012 Whats Up NumberCall Girls Delhi {Rs-10000 Laxmi Nagar] 9711199012 Whats Up Number
Call Girls Delhi {Rs-10000 Laxmi Nagar] 9711199012 Whats Up NumberMs Riya
 
Hifi Defence Colony Call Girls Service WhatsApp -> 9999965857 Available 24x7 ...
Hifi Defence Colony Call Girls Service WhatsApp -> 9999965857 Available 24x7 ...Hifi Defence Colony Call Girls Service WhatsApp -> 9999965857 Available 24x7 ...
Hifi Defence Colony Call Girls Service WhatsApp -> 9999965857 Available 24x7 ...srsj9000
 
Low Rate Call Girls Nashik Vedika 7001305949 Independent Escort Service Nashik
Low Rate Call Girls Nashik Vedika 7001305949 Independent Escort Service NashikLow Rate Call Girls Nashik Vedika 7001305949 Independent Escort Service Nashik
Low Rate Call Girls Nashik Vedika 7001305949 Independent Escort Service NashikCall Girls in Nagpur High Profile
 
如何办理(Adelaide毕业证)阿德莱德大学毕业证成绩单Adelaide学历认证真实可查
如何办理(Adelaide毕业证)阿德莱德大学毕业证成绩单Adelaide学历认证真实可查如何办理(Adelaide毕业证)阿德莱德大学毕业证成绩单Adelaide学历认证真实可查
如何办理(Adelaide毕业证)阿德莱德大学毕业证成绩单Adelaide学历认证真实可查awo24iot
 
High Profile Call Girls In Andheri 7738631006 Call girls in mumbai Mumbai ...
High Profile Call Girls In Andheri 7738631006 Call girls in mumbai  Mumbai ...High Profile Call Girls In Andheri 7738631006 Call girls in mumbai  Mumbai ...
High Profile Call Girls In Andheri 7738631006 Call girls in mumbai Mumbai ...Pooja Nehwal
 
Russian Call Girls In South Delhi Delhi 9711199012 💋✔💕😘 Independent Escorts D...
Russian Call Girls In South Delhi Delhi 9711199012 💋✔💕😘 Independent Escorts D...Russian Call Girls In South Delhi Delhi 9711199012 💋✔💕😘 Independent Escorts D...
Russian Call Girls In South Delhi Delhi 9711199012 💋✔💕😘 Independent Escorts D...nagunakhan
 
VIP Call Girls Kavuri Hills ( Hyderabad ) Phone 8250192130 | ₹5k To 25k With ...
VIP Call Girls Kavuri Hills ( Hyderabad ) Phone 8250192130 | ₹5k To 25k With ...VIP Call Girls Kavuri Hills ( Hyderabad ) Phone 8250192130 | ₹5k To 25k With ...
VIP Call Girls Kavuri Hills ( Hyderabad ) Phone 8250192130 | ₹5k To 25k With ...Suhani Kapoor
 
如何办理(UCLA毕业证书)加州大学洛杉矶分校毕业证成绩单留信学历认证原版一比一
如何办理(UCLA毕业证书)加州大学洛杉矶分校毕业证成绩单留信学历认证原版一比一如何办理(UCLA毕业证书)加州大学洛杉矶分校毕业证成绩单留信学历认证原版一比一
如何办理(UCLA毕业证书)加州大学洛杉矶分校毕业证成绩单留信学历认证原版一比一ga6c6bdl
 
VVIP Pune Call Girls Balaji Nagar (7001035870) Pune Escorts Nearby with Compl...
VVIP Pune Call Girls Balaji Nagar (7001035870) Pune Escorts Nearby with Compl...VVIP Pune Call Girls Balaji Nagar (7001035870) Pune Escorts Nearby with Compl...
VVIP Pune Call Girls Balaji Nagar (7001035870) Pune Escorts Nearby with Compl...Call Girls in Nagpur High Profile
 
(PARI) Alandi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
(PARI) Alandi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts(PARI) Alandi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
(PARI) Alandi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escortsranjana rawat
 
Beautiful Sapna Call Girls CP 9711199012 ☎ Call /Whatsapps
Beautiful Sapna Call Girls CP 9711199012 ☎ Call /WhatsappsBeautiful Sapna Call Girls CP 9711199012 ☎ Call /Whatsapps
Beautiful Sapna Call Girls CP 9711199012 ☎ Call /Whatsappssapnasaifi408
 
哪里办理美国宾夕法尼亚州立大学毕业证(本硕)psu成绩单原版一模一样
哪里办理美国宾夕法尼亚州立大学毕业证(本硕)psu成绩单原版一模一样哪里办理美国宾夕法尼亚州立大学毕业证(本硕)psu成绩单原版一模一样
哪里办理美国宾夕法尼亚州立大学毕业证(本硕)psu成绩单原版一模一样qaffana
 
(MEGHA) Hinjewadi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune E...
(MEGHA) Hinjewadi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune E...(MEGHA) Hinjewadi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune E...
(MEGHA) Hinjewadi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune E...ranjana rawat
 
Vip Noida Escorts 9873940964 Greater Noida Escorts Service
Vip Noida Escorts 9873940964 Greater Noida Escorts ServiceVip Noida Escorts 9873940964 Greater Noida Escorts Service
Vip Noida Escorts 9873940964 Greater Noida Escorts Serviceankitnayak356677
 
9004554577, Get Adorable Call Girls service. Book call girls & escort service...
9004554577, Get Adorable Call Girls service. Book call girls & escort service...9004554577, Get Adorable Call Girls service. Book call girls & escort service...
9004554577, Get Adorable Call Girls service. Book call girls & escort service...Pooja Nehwal
 
Thane Escorts, (Pooja 09892124323), Thane Call Girls
Thane Escorts, (Pooja 09892124323), Thane Call GirlsThane Escorts, (Pooja 09892124323), Thane Call Girls
Thane Escorts, (Pooja 09892124323), Thane Call GirlsPooja Nehwal
 
WhatsApp 9892124323 ✓Call Girls In Khar ( Mumbai ) secure service - Bandra F...
WhatsApp 9892124323 ✓Call Girls In Khar ( Mumbai ) secure service -  Bandra F...WhatsApp 9892124323 ✓Call Girls In Khar ( Mumbai ) secure service -  Bandra F...
WhatsApp 9892124323 ✓Call Girls In Khar ( Mumbai ) secure service - Bandra F...Pooja Nehwal
 

Recently uploaded (20)

Russian Call Girls Kolkata Chhaya 🤌 8250192130 🚀 Vip Call Girls Kolkata
Russian Call Girls Kolkata Chhaya 🤌  8250192130 🚀 Vip Call Girls KolkataRussian Call Girls Kolkata Chhaya 🤌  8250192130 🚀 Vip Call Girls Kolkata
Russian Call Girls Kolkata Chhaya 🤌 8250192130 🚀 Vip Call Girls Kolkata
 
Call Girls in Dwarka Sub City 💯Call Us 🔝8264348440🔝
Call Girls in Dwarka Sub City 💯Call Us 🔝8264348440🔝Call Girls in Dwarka Sub City 💯Call Us 🔝8264348440🔝
Call Girls in Dwarka Sub City 💯Call Us 🔝8264348440🔝
 
Call Girls Delhi {Rs-10000 Laxmi Nagar] 9711199012 Whats Up Number
Call Girls Delhi {Rs-10000 Laxmi Nagar] 9711199012 Whats Up NumberCall Girls Delhi {Rs-10000 Laxmi Nagar] 9711199012 Whats Up Number
Call Girls Delhi {Rs-10000 Laxmi Nagar] 9711199012 Whats Up Number
 
Hifi Defence Colony Call Girls Service WhatsApp -> 9999965857 Available 24x7 ...
Hifi Defence Colony Call Girls Service WhatsApp -> 9999965857 Available 24x7 ...Hifi Defence Colony Call Girls Service WhatsApp -> 9999965857 Available 24x7 ...
Hifi Defence Colony Call Girls Service WhatsApp -> 9999965857 Available 24x7 ...
 
Low Rate Call Girls Nashik Vedika 7001305949 Independent Escort Service Nashik
Low Rate Call Girls Nashik Vedika 7001305949 Independent Escort Service NashikLow Rate Call Girls Nashik Vedika 7001305949 Independent Escort Service Nashik
Low Rate Call Girls Nashik Vedika 7001305949 Independent Escort Service Nashik
 
如何办理(Adelaide毕业证)阿德莱德大学毕业证成绩单Adelaide学历认证真实可查
如何办理(Adelaide毕业证)阿德莱德大学毕业证成绩单Adelaide学历认证真实可查如何办理(Adelaide毕业证)阿德莱德大学毕业证成绩单Adelaide学历认证真实可查
如何办理(Adelaide毕业证)阿德莱德大学毕业证成绩单Adelaide学历认证真实可查
 
🔝 9953056974🔝 Delhi Call Girls in Ajmeri Gate
🔝 9953056974🔝 Delhi Call Girls in Ajmeri Gate🔝 9953056974🔝 Delhi Call Girls in Ajmeri Gate
🔝 9953056974🔝 Delhi Call Girls in Ajmeri Gate
 
High Profile Call Girls In Andheri 7738631006 Call girls in mumbai Mumbai ...
High Profile Call Girls In Andheri 7738631006 Call girls in mumbai  Mumbai ...High Profile Call Girls In Andheri 7738631006 Call girls in mumbai  Mumbai ...
High Profile Call Girls In Andheri 7738631006 Call girls in mumbai Mumbai ...
 
Russian Call Girls In South Delhi Delhi 9711199012 💋✔💕😘 Independent Escorts D...
Russian Call Girls In South Delhi Delhi 9711199012 💋✔💕😘 Independent Escorts D...Russian Call Girls In South Delhi Delhi 9711199012 💋✔💕😘 Independent Escorts D...
Russian Call Girls In South Delhi Delhi 9711199012 💋✔💕😘 Independent Escorts D...
 
VIP Call Girls Kavuri Hills ( Hyderabad ) Phone 8250192130 | ₹5k To 25k With ...
VIP Call Girls Kavuri Hills ( Hyderabad ) Phone 8250192130 | ₹5k To 25k With ...VIP Call Girls Kavuri Hills ( Hyderabad ) Phone 8250192130 | ₹5k To 25k With ...
VIP Call Girls Kavuri Hills ( Hyderabad ) Phone 8250192130 | ₹5k To 25k With ...
 
如何办理(UCLA毕业证书)加州大学洛杉矶分校毕业证成绩单留信学历认证原版一比一
如何办理(UCLA毕业证书)加州大学洛杉矶分校毕业证成绩单留信学历认证原版一比一如何办理(UCLA毕业证书)加州大学洛杉矶分校毕业证成绩单留信学历认证原版一比一
如何办理(UCLA毕业证书)加州大学洛杉矶分校毕业证成绩单留信学历认证原版一比一
 
VVIP Pune Call Girls Balaji Nagar (7001035870) Pune Escorts Nearby with Compl...
VVIP Pune Call Girls Balaji Nagar (7001035870) Pune Escorts Nearby with Compl...VVIP Pune Call Girls Balaji Nagar (7001035870) Pune Escorts Nearby with Compl...
VVIP Pune Call Girls Balaji Nagar (7001035870) Pune Escorts Nearby with Compl...
 
(PARI) Alandi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
(PARI) Alandi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts(PARI) Alandi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
(PARI) Alandi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
 
Beautiful Sapna Call Girls CP 9711199012 ☎ Call /Whatsapps
Beautiful Sapna Call Girls CP 9711199012 ☎ Call /WhatsappsBeautiful Sapna Call Girls CP 9711199012 ☎ Call /Whatsapps
Beautiful Sapna Call Girls CP 9711199012 ☎ Call /Whatsapps
 
哪里办理美国宾夕法尼亚州立大学毕业证(本硕)psu成绩单原版一模一样
哪里办理美国宾夕法尼亚州立大学毕业证(本硕)psu成绩单原版一模一样哪里办理美国宾夕法尼亚州立大学毕业证(本硕)psu成绩单原版一模一样
哪里办理美国宾夕法尼亚州立大学毕业证(本硕)psu成绩单原版一模一样
 
(MEGHA) Hinjewadi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune E...
(MEGHA) Hinjewadi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune E...(MEGHA) Hinjewadi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune E...
(MEGHA) Hinjewadi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune E...
 
Vip Noida Escorts 9873940964 Greater Noida Escorts Service
Vip Noida Escorts 9873940964 Greater Noida Escorts ServiceVip Noida Escorts 9873940964 Greater Noida Escorts Service
Vip Noida Escorts 9873940964 Greater Noida Escorts Service
 
9004554577, Get Adorable Call Girls service. Book call girls & escort service...
9004554577, Get Adorable Call Girls service. Book call girls & escort service...9004554577, Get Adorable Call Girls service. Book call girls & escort service...
9004554577, Get Adorable Call Girls service. Book call girls & escort service...
 
Thane Escorts, (Pooja 09892124323), Thane Call Girls
Thane Escorts, (Pooja 09892124323), Thane Call GirlsThane Escorts, (Pooja 09892124323), Thane Call Girls
Thane Escorts, (Pooja 09892124323), Thane Call Girls
 
WhatsApp 9892124323 ✓Call Girls In Khar ( Mumbai ) secure service - Bandra F...
WhatsApp 9892124323 ✓Call Girls In Khar ( Mumbai ) secure service -  Bandra F...WhatsApp 9892124323 ✓Call Girls In Khar ( Mumbai ) secure service -  Bandra F...
WhatsApp 9892124323 ✓Call Girls In Khar ( Mumbai ) secure service - Bandra F...
 

CACHE SIMULATOR WITH FIFO AND LRU REPLACEMENT

  • 1. CACHE SIMULATOR PRESENTED BY - SURAJ KUMAR SAINI SANCHIT JAIN RAHUL RAWAT NARESH BILONIYA 1
  • 2. OVERVIEW • Cache Memory • Types of cache • CACHE SIMULATOR • Cache Mapping • CACHE HIT/MISS • WRITE POLICY • REPLACEMENT ALGORITHM 2
  • 3. CACHE MEMORY • A cache is a hardware or software component that stores data so that for future requests that data can be served faster. • Cache memory is used in order to achieve higher performance of CPU by allowing the CPU to access data at faster speed. 3
  • 4. TYPES OF CACHE • L1 , L2 , L3 cache are built to decrease the time taken to access data by the processor .This time taken is called latency. • L1 cache(2KB-64KB) : it is smaller in size and the instructions are first searched in it. • L2 cache(256KB-512KB) : it is comparatively larger in size and the instructions not found in the L1 are searched here. • L3 cache(1MB – 8MB) : Size is largest among all cache and instructions not found in L2 are searched here. 4
  • 5. CACHE SIMULATOR  This project simulates a write through or a write back direct mapped cache in C.  It calculates the number of memory writes and memory reads for a memory access pattern provided as a file.  It computes the number of cache hits and misses as well as the number of main memory reads and writes. 5
  • 6. Cache mapping divided in three category: • Direct Mapped • Associative • Set Associative CACHE MAPPING6
  • 7. The direct mapping technique is simple and inexpensive to implement. When the CPU wants to access data from memory, it places a address. The index field of CPU address is used to access address. The tag field of CPU address is compared with the associated tag in the word read from the cache. If the tag-bits of CPU address is matched with the tag-bits of cache, then there is a hit and the required data word is read from cache. 7 DIRECT MAPPED
  • 9. ASSOCIATIVE CACHE • This mapping scheme attempts to improve cache utilization. • In associative cache mapping, the data from any location in RAM can be stored in any location in cache • When the processor wants an address, all tag fields in the cache as checked to determine if the data is already in the cache • Each tag line requires circuitry to compare the desired address with the tag field • All tag fields are checked in parallel 9
  • 10. SET ASSOCIATIVE MAPPING • Set associative mapping is a mixture of direct and associative mapping • The cache lines are grouped into sets • The number of lines in a set can vary from 2 to 16 • A portion of the address is used to specify which set will hold an address • The data can be stored in any of the lines in the set 10
  • 11. CACHE HIT/MISS Cache Hit • A cache hit is a state in which data requested for processing by a component or application is found in the cache memory. • It is a faster means of delivering data to the processor, as the cache already contains the requested data. Cache Miss • Cache miss is a state where the data requested for processing by a component or application is not found in the cache memory. • It causes execution delays by requiring the program or application to fetch the data from other cache levels or the main memory. 11
  • 12. WRITE POLICY • The cache's write policy determines how it handles writes to memory locations that are currently being held in cache. • These two popular cache write policies (schemes) are: 1. Write-Through 2. Write-Back 12
  • 13. Write-Back Cache • When the system writes to a memory location that is currently held in cache, it only writes the new information to the appropriate cache line. When the cache line is eventually needed for some other memory address, the changed data is "written back" to system memory. • This type of cache provides better performance than a write-through cache, because it saves on (time-consuming) write cycles to memory. 13
  • 14. WRITE-THROUGH CACHE • When the system writes to a memory location that is currently held in cache, it writes the new information both to the appropriate cache line and the memory location itself at the same time. • This type of caching provides worse performance than write-back, but is simpler to implement and has the advantage of internal consistency, because the cache is never out of sync with the memory the way it is with a write-back cache 14
  • 15. REPLACEMENT ALGORITHM • Replacement algorithms are used when there are no available space in a cache in which to place a data. • In this cache simulator, we have used FIFO and LRU Replacement Algorithms. • Factors to consider 1. Read/Write Balance. (What percentage of accesses are reads vs writes) 2. Amount of cache. 3. Type of media behind the cache. (Are they slow SATA drives or fast SSD drives?) 4. Hits vs Misses. (How often are things rewritten or reread?) 5. Average access size (This goes into choose the page size) 6. How expensive are reads and writes. 15
  • 16. FIRST IN FIRST OUT • The FIFO algorithm selects for replacement the item that has been in the cache from the longest time. • Using this algorithm the cache behaves in the same way as a FIFO queue. The cache evicts the first block accessed first without any regard to how often or how many times it was accessed before. 16
  • 17. LEAST RECENTLY USED • The LRU caching scheme is used to remove the least recently used item when the cache is full and a new item is referenced which is not there in cache. • This algorithm requires keeping track of what was used when, which is expensive if one wants to make sure the algorithm always discards the least recently used item. 17
  • 18. IMPLEMENTATION IN SIMULATOR • FIFO using Queue: A FIFO cache is one that uses queuing logic for its backing store, expunging the elements at the front of the queue when a predetermined threshold is exceeded. For implementing queue using array, we keep track of two indices, front and rear. We enqueue an item at the rear and dequeue an item from front. • LRU using Doubly Linked List : To implement LRU keep the doubly-linked list in each set sorted by the order in which the cache lines were referenced. This can be done by removing a cache line from the linked list each time you reference it, and inserting it back into the linked list at the head. In this case, you should always evict the cache line at the tail of the list . 18
  • 19. SIMULATOR OUTPUT • Total Hit Rate: The percentage of memory cache (i.e. lines in the trace file) that were hits. This number should be truncated to 4 decimal places of precision. • Total Run Time: The total run time of the program, assuming that the last memory access was the last instruction of the program. The unit for this should be cycles. • Average Memory Access Latency: The average number of cycles needed to complete a memory access. This number should be to 4 decimal places of precision. 19