Snoopy protocols helps to achieve data consistent between the cache memory and the shared memory through bus-based memory system.
Write-invalidation and write-update policies are used for maintaining cache consistency.
We have three processors P1, P2, and P3 having a consistent copy of data element X in their local cache memory and in the shared memory.
Processors P1 writes X1 in it's cache memory using write-invalidate protocol. So , all other copies are invalidated via the bus . It is denoted by 'I'. Invalidated blocks are also known as dirty, i.e. they should not be used
The write-update protocol updates all the cache copies via the bus. By using write back cache, the memory copy is also updated.
In snooping protocol, transactions on bus are visible to all processors. Processors or bus watching mechanisms can snoop(monitor) the bus and take action on relevant events (e.g: change state) to ensure data inconsistency among the private caches and the shared memory.
WRITE INVALIDATE BUS SNOOPING PROTOCOL (for write through cache)
The state of a cache block copy of local processor can take one of the two states:
Valid state:
- All processors can read safely.
- Local processor can also write.
- Block being invalidated
- Block being replaced
- When a remote processor writes to its cache copy, all other cache copies become invalidated
WRITE INVALIDATE BUS SNOOPING PROTOCOL (for write back cache)
Validate state can be split in to two: Read-write and read only
WRITE ONCE PROTOCOL
It is the first snoopy cache protocol
multiple memory readers allowed simultaneously, not multiple writers.
The four cache states are :
- Valid: Cache block is consistent with memory copy; has been read from shared memory and has not been modified
- Invalid :Block is not found in cache or is inconsistent with the memory copy.
- Reserved: The block is the only copy of the memory, but it is still coherent.No write back is needed if the block is replaced.
- Dirty: The cache block has been modified more than once, and it is incoherent.This copy was written one or more times
CACHE EVENTS AND ACTIONS
Following events and actions occur on the execution of memory-access and invalidation commands −
Read-miss:When a processor want to read a block and it is not in the cache, a read-miss occurs. This initiates a bus-read operation.if no dirty copy exists, then the main memory that has a consistent copy, supplies a copy to the requesting cache memory. If a dirty copy exists in a remote cache memory, that cache will restrain the main memory and send a copy to the requesting cache memory. In both cases cache copy will enter valid state after a read miss.
Write hit: If the copy is in dirty or reserved state, write is done locally and the new state is dirty. If the new state is valid, write invalidate command is broadcasted to all the caches, invalidating their copies. When the shared memory is written through, the resulting state is reserved after this first write.
Write miss: If a processor fails to write in the in the local cache memory, the copy must come either from the main memory or from a remote cache memory with a dirty block. This is done by sending a read-invalidate command, which will invalidate all cache copies. Then the local copy is updated with dirty state.
Read hit: Read hit is always performed in local cache memory without causing a transition of state or using the snoopy bus for invalidation.
Block replacement: When a copy is dirty, it is to written back to the main memory by block replacement method. However, when the copy is either valid or reserved state, no replacement will take place.
Write hit: If the copy is in dirty or reserved state, write is done locally and the new state is dirty. If the new state is valid, write invalidate command is broadcasted to all the caches, invalidating their copies. When the shared memory is written through, the resulting state is reserved after this first write.
Write miss: If a processor fails to write in the in the local cache memory, the copy must come either from the main memory or from a remote cache memory with a dirty block. This is done by sending a read-invalidate command, which will invalidate all cache copies. Then the local copy is updated with dirty state.
Read hit: Read hit is always performed in local cache memory without causing a transition of state or using the snoopy bus for invalidation.
Block replacement: When a copy is dirty, it is to written back to the main memory by block replacement method. However, when the copy is either valid or reserved state, no replacement will take place.
- .
Comments
Post a Comment