MESI Protocol
MESI Protocol
MESI PROTOCOL
ØÊÊWriteÊPoliciesÊ/ÊCacheÊConsistencyÊ/ÊCacheÊCoherency
1.ÊThough cache memory has massive speed advantage, it comes with an inherent
drawback. Dur to cache, there are two copies of the same data, one in cache memory and
the other in Main Memory.
2.ÊAsÊlongÊasÊbothÊareÊtheÊsameÊtheÊcacheÊisÊsaidÊtoÊbeÊconsistentÊ(coherent).ÊInconsistencyÊarisesÊ
theÊmomentÊaÊprocessorÊperformsÊaÊwriteÊoperation.
3.ÊThe write will be performed on the cache, as that’s the whole idea of having cache
memory in the first place. This means the same data in the main memory now has an old
(stale/invalid) value. If another bus master (co-processor) accesses the same data from the
Main Memory, it will get stale value. Hence the cache becomes inconsistent. This can be
avoided by having good write policies. There are several policies suggested.
ØÊWriteÊThrough
1.ÊWhen a processor writes into Cache Memory, it must also write in Main Memory.
2.ÊThisÊcompletelyÊsolvesÊtheÊproblemÊofÊinconsistencyÊbutÊmakesÊwritesÊslowÊasÊwritingÊintoÊ
MainÊMemoryÊisÊmuchÊslowerÊasÊcomparedÊtoÊreads.ÊItsÊnotÊallÊthatÊbadÊbecauseÊonÊanÊaverageÊ
majorityÊoperationsÊareÊreadsÊcomparedÊtoÊwrites.
ØÊWriteÊBackÊ(DelayedÊWriteÊ/ÊPostedÊWriteÊ/ÊBufferedÊWrite)
1. Processor will only write into Cache Memory. A Cache Controller (Eg: Intel’s 80385)
keeps a track of all blocks that have been modified in the Cache Memory.
2.ÊWhenÊtheÊprocessorÊisÊidleÊorÊatÊtheÊtimeÊwhenÊthisÊblockÊhasÊtoÊbeÊreplaced,ÊitÊwillÊcopyÊallÊ
modifiedÊinformationÊfromÊCacheÊMemoryÊtoÊMainÊMemory.ÊThisÊmakesÊprocessor’sÊwritesÊveryÊ
fastÊbutÊkeepsÊtheÊMainÊMemoryÊinconsistentÊforÊsometime.
ØÊÊSNOOPINGÊ
1. Processor will only write into Cache Memory. A Cache Controller (Eg: Intel’s 80835)
keeps a track of all blocks that have been modified in the Cache Memory. Additionally the
Cache Controller will “Snoop” activities of other bus masters.
2.ÊIfÊitÊnoticesÊthatÊanotherÊbusÊmasterÊisÊtryingÊtoÊaccessÊaÊlocationÊfromÊMainÊMemoryÊwhichÊ
hasÊbeenÊmodifiedÊinÊtheÊCacheÊMemory,ÊtheÊCacheÊControllerÊwillÊstopÊactivitiesÊofÊallÊbusÊ
masters,ÊcopyÊupdatedÊdataÊfromÊCacheÊMemoryÊtoÊMainÊMemoryÊandÊallowÊtheÊsystemÊtoÊ
resume.ÊThisÊgivesÊtotalÊconsistencyÊandÊalsoÊpreventsÊunnecessaryÊupdatesÊtoÊmainÊmemoryÊ
henceÊgivesÊtheÊbestÊperformance.