Cache coherence is the natural problem that develops when a system's data set is accessed and altered by multiple agents. The primary area of computer architecture where this becomes a problem is in multiprocessor computers. Each processor in a multiprocessor computer has its own cache that loads and stores information from the random access memory (RAM). When two processors are accessing the same area of memory, cache coherence would be lost if certain precautions were not taken.
Without cache coherence, a multiprocessor system would be unable to function. There are several methods that have been developed in order to address this issue and avoid potential problems. Directory-based coherence, snooping and snarfing are three methods that are used to prevent the loss of cache coherence.
Directory-based coherence works as a filter in order to ensure coherence. Data is placed within a portion of memory that is accessible to all of the processors. When the information that is stored within that area of memory is changed, the system will either update the caches or invalidate them.
Snooping requires the processor to monitor all of the accesses to the memory locations that have been cached. This enables the processor to know when a write operation has occurred. By knowing when a write operation occurs, the processor can update its cache.
Snarfing is quite similar to snooping. Snarfing involves not only monitoring the accesses to memory locations that have been cached but also monitoring the actual information that is stored in the memory. When a memory write occurs, the cache can be updated with the new information.
Directory-based coherence systems have a relatively high latency, resulting in slower processing. Lower bandwidth requirements enable directory-based coherence systems to be practical in large scale applications of cache coherence. The more processors that a system uses, the more advantages it can have from using a directory-based coherence system.
Snooping is a much faster method. This method requires more bandwidth than the directory-based approach. This method is able to be used effectively in systems that have relatively few processors.
Snarfing is not usually used as a method of maintaining cache coherence. This is primarily because snarfing requires more resources to be used as compared to both snooping and directory-based methods. In order for a snarfing system to work, it must keep track of both the memory addresses and the data stored in those areas of memory. The amount of bandwidth and processing that is taken up by this method makes it undesirable for most applications of maintaining cache coherence.