So, for example, if processors P1 and P2 have shared copies of address A1 cached, and processor P3 wants an exclusive copy, P3 sends a request for an exclusive copy to the memory, the memory sends invalidate messages to P1 and P2, P1 and P2 discard their copies of A1 and send invalidate acknowledgments back to the memory, and when the memory receives all the acknowledgments, it sends an exclusive copy to P3.
In order to avoid trying to model a real cache (with tag bits and replacement policies, etc.), we give each processor a cache big enough to hold all of memory.
For each address in the cache, the cache line can be in one of five states: Exclusive, Shared, Invalid, WaitExclusive, and WaitShared. The Exclusive, Shared, and Invalid states have the obvious meanings. The Wait states indicate the processor has sent a request for a shared or exclusive copy of this line, but hasn't received the reply from the memory yet. In addition, each cache line has a value field that indicates the current value cached for that address.
The WaitingWriteBack and WaitingInvalidate states indicate that this address is waiting to receive a writeback or invalidate before a pending request (some processor has requested shared or exclusive) can be served. When the writeback or last invalidate acknowledgment has arrived, the memory completes the transcation by sending the data reply to the processor indicated by the replyto field and setting its state to the value indicated by the replytype field.
If a request arrives for an address for which there is already a pending request, the memory sends a Retry message back to the requestor.
Processors can send messages to memory. There are four possible message types a processor can send: ReqShared, ReqExclusive, InvAck and WriteBack. ReqShared and ReqExclusive request a shared or exclusive copy of an address from memory. InvAck is an invalidate acknowledgment, and WriteBack writes back data that had been cached exclusive.
There are four possible message types that memory can send to a processor: Data, Invalidate, ForcedWriteBack, and Retry. A Data message delivers data to the processor that requested it. Invalidate asks a processor to invalidate it's shared copy of an address. ForcedWriteBack asks a processor to write back its exclusively cached copy of an address. Retry tells a processor that the memory can't handle it's most recent request.
We will model the network as two multisets of messages. The multiset datatype is a Murphi data structure that gives an unordered collection of objects (in this case, messages). Murphi automatically provides symmetry reductions for multisets.
Present State: | | | New State: | Send Message: | Update Cached Value: | Comments: |
Invalid | | | WaitShared | ReqShared | Wants shared copy. | |
Invalid | | | WaitExclusive | ReqExclusive | Wants exclusive copy. | |
Exclusive | | | Invalid | WriteBack | Undefined | Spontaneous write back. |
Shared | | | Invalid | Undefined | Eviction of shared. | |
Exclusive | | | Exclusive | Non-deterministic | Can write arbitrary value. |
Message: | Present State: | | | New State: | Send Message: | Update Cached Value: | Comments: |
Data | WaitShared | | | Shared | From Message | Shared req answered. | |
Data | WaitExclusive | | | Exclusive | From Message | Exclusive req answered. | |
Data | Invalid | | | Invalid | Stale data message. Discard. | ||
ForceWriteBack | Exclusive | | | Invalid | WriteBack | Undefined | Normal writeback. |
ForceWriteBack | WaitExclusive | | | Invalid | InvAck | ForcedWriteBack arrived before Data. Send an InvAck to distinguish this case. Will discard stale data when it arrives. | |
ForceWriteBack | anything else | | | I must have written back already. Ignore. | |||
Invalidate | Shared | | | Invalid | InvAck | Undefined | Normal invalidate. |
Invalidate | WaitShared | | | Invalid | InvAck | Invalidate arrived before Data. Will discard stale data when it arrives. | |
Invalidate | anything else | | | InvAck | I must have evicted already. Acknowledge invalidate. | ||
Retry | WaitShared | | | Invalid | Failed request. | ||
Retry | WaitExclusive | | | Invalid | Failed request. |
Message | Present State | Sender Cached | Last Sender | | | New State | Send Message | Update Memory Value | Update Sharing List | Set replyto | Set replytype | Comments |
ReqShared | Uncached | | | CachedShared | Data | Add Sender | First sharing request | |||||
ReqShared | CachedShared | | | CachedShared | Data | Add Sender | Add'l sharing request | |||||
ReqShared | CachedExclusive | Yes | | | CachedExclusive | Retry | Haven't received previous write back yet | |||||
ReqShared | CachedExclusive | No | | | WaitingWriteBack | ForceWriteBack | Sender | CachedShared | Must get write back before responding | |||
ReqShared | WaitingWriteBack | | | WaitingWriteBack | Retry | Pending transaction | ||||||
ReqShared | WaitingInvalidate | | | WaitingInvalidate | Retry | Pending transaction | ||||||
ReqExclusive | Yes | | | Retry | Haven't received write back yet | |||||||
ReqExclusive | Uncached | No | | | CachedExclusive | Data | Add Sender | Normal exclusive req | ||||
ReqExclusive | CachedShared | No | | | WaitingInvalidate | Invalidate All | Sender | CachedExclusive | Must invalidate sharers before responding | |||
ReqExclusive | CachedExclusive | No | | | WaitingWriteBack | Invalidate All | Sender | CachedExclusive | Must get write back before responding | |||
ReqExclusive | WaitingWriteBack | No | | | WaitingWriteBack | Retry | Pending transaction | |||||
ReqExclusive | WaitingInvalidate | No | | | WaitingInvalidate | Retry | Pending transaction | |||||
WriteBack | CachedExclusive | | | Uncached | From Message | Delete Sender | Normal write back | |||||
WriteBack | WaitingWriteBack | | | From replytype | Data to replyto | From Message | Delete Sender, Add replyto | Undefined | Undefined | Forced write back | ||
InvAck | WaitingInvalidate | No | | | WaitingInvalidate | Delete Sender | Normal invalidate | |||||
InvAck | WaitingInvalidate | Yes | | | From replytype | Data to replyto | Delete Sender, Add replyto | Undefined | Undefined | Last invalidate | ||
InvAck | WaitingWriteBack | | | From replytype | Data to replyto | Delete Sender, Add replyto | Undefined | Undefined | Proc was forced to write back before data message arrived. Can proceed as if write back occurred. |
For the new state, ``From replytype'' indicates that the new state is copied from the value set in the replytype variable.