private void ReadRequestUpdownFinish(CoherentCacheNode source, uint @set, uint way, DirectoryLock dirLock, ref uint pending, Action<bool, bool> onCompletedCallback) { pending--; if (pending == 0) { DirectoryEntry dirEntry = this.Cache.Directory.Entries[(int)@set][(int)way]; if (dirEntry.Owner != null && dirEntry.Owner != source) { dirEntry.Owner = null; } dirEntry.SetSharer (source); if (!dirEntry.IsShared) { dirEntry.Owner = source; } this.Cache.AccessLine (@set, way); dirLock.Unlock (); this.Schedule (() => onCompletedCallback (false, dirEntry.IsShared), 2); } }
private void WriteRequestUpdownFinish(CoherentCacheNode source, bool hasError, uint @set, uint way, uint tag, MESIState state, DirectoryLock dirLock, Action<bool> onCompletedCallback) { if (!hasError) { DirectoryEntry dirEntry = this.Cache.Directory.Entries[(int)@set][(int)way]; dirEntry.SetSharer (source); dirEntry.Owner = source; this.Cache.AccessLine (@set, way); if (state != MESIState.Modified) { this.Cache.SetLine (@set, way, tag, MESIState.Exclusive); } dirLock.Unlock (); this.Schedule (() => onCompletedCallback (false), 2); } else { dirLock.Unlock (); this.Schedule (() => onCompletedCallback (true), 2); } }
private void EvictWritebackFinish(CoherentCacheNode source, bool hasError, uint @set, uint way, uint tag, DirectoryLock dirLock, Action<bool> onReceiveReplyCallback) { if (!hasError) { this.Cache.SetLine (@set, way, tag, MESIState.Modified); this.Cache.AccessLine (@set, way); this.EvictProcess (source, @set, way, dirLock, onReceiveReplyCallback); } else { dirLock.Unlock (); onReceiveReplyCallback (true); } }
private void ReadRequestUpdown(CoherentCacheNode source, uint @set, uint way, uint tag, MESIState state, DirectoryLock dirLock, Action<bool, bool> onCompletedCallback) { uint pending = 1; if (state != MESIState.Invalid) { DirectoryEntry dirEntry = this.Cache.Directory.Entries[(int)@set][(int)way]; if (dirEntry.Owner != null && dirEntry.Owner != source) { pending++; this.ReadRequest (dirEntry.Owner, tag, (hasError, isShared) => this.ReadRequestUpdownFinish (source, @set, way, dirLock, ref pending, onCompletedCallback)); } this.ReadRequestUpdownFinish (source, @set, way, dirLock, ref pending, onCompletedCallback); } else { this.ReadRequest (this.Next, tag, (hasError, isShared) => { if (!hasError) { this.Cache.SetLine (@set, way, tag, isShared ? MESIState.Shared : MESIState.Exclusive); this.ReadRequestUpdownFinish (source, @set, way, dirLock, ref pending, onCompletedCallback); } else { dirLock.Unlock (); this.Schedule (() => onCompletedCallback (true, false), 2); } }); } }
public void SetSharer(CoherentCacheNode node) { Debug.Assert (node != null); if (!this.Sharers.Contains (node)) { this.Sharers.Add (node); } }
private void EvictProcess(CoherentCacheNode source, uint @set, uint way, DirectoryLock dirLock, Action<bool> onReceiveReplyCallback) { DirectoryEntry dirEntry = this.Cache.Directory.Entries[(int)@set][(int)way]; dirEntry.UnsetSharer (source); if (dirEntry.Owner == source) { dirEntry.Owner = null; } dirLock.Unlock (); onReceiveReplyCallback (false); }
public override void ReadRequestReceive(CoherentCacheNode source, uint addr, Action<bool, bool> onCompletedCallback) { this.FindAndLock (addr, this.Next == source, true, false, (hasError, @set, way, state, tag, dirLock) => { if (!hasError) { if (source.Next == this) { this.ReadRequestUpdown (source, @set, way, tag, state, dirLock, onCompletedCallback); } else { this.ReadRequestDownup (@set, way, tag, dirLock, onCompletedCallback); } } else { this.Schedule (() => onCompletedCallback (true, false), 2); } }); }
public virtual void ReadRequest(CoherentCacheNode target, uint addr, Action<bool, bool> onCompletedCallback) { throw new NotImplementedException (); }
public override void EvictReceive(CoherentCacheNode source, uint addr, bool isWriteback, Action<bool> onReceiveReplyCallback) { this.FindAndLock (addr, false, false, false, (hasError, @set, way, state, tag, dirLock) => { if (!hasError) { if (!isWriteback) { this.EvictProcess (source, @set, way, dirLock, onReceiveReplyCallback); } else { this.Invalidate (source, @set, way, () => { if (state == MESIState.Shared) { this.WriteRequest (this.Next, tag, hasError1 => this.EvictWritebackFinish (source, hasError1, @set, way, tag, dirLock, onReceiveReplyCallback)); } else { this.EvictWritebackFinish (source, false, @set, way, tag, dirLock, onReceiveReplyCallback); } }); } } else { onReceiveReplyCallback (true); } }); }
public override void Invalidate(CoherentCacheNode except, uint @set, uint way, Action onCompletedCallback) { uint tag; MESIState state; this.Cache.GetLine (@set, way, out tag, out state); uint pending = 1; DirectoryEntry dirEntry = this.Cache.Directory.Entries[(int)@set][(int)way]; foreach (var sharer in dirEntry.Sharers.FindAll (sharer => sharer != except)) { dirEntry.UnsetSharer (sharer); if (dirEntry.Owner == sharer) { dirEntry.Owner = null; } this.WriteRequest (sharer, tag, hasError => { pending--; if (pending == 0) { onCompletedCallback (); } }); pending++; } pending--; if (pending == 0) { onCompletedCallback (); } }
public override void WriteRequestReceive(CoherentCacheNode source, uint addr, Action<bool> onCompletedCallback) { this.Stat.Accesses++; this.Stat.Writes++; this.Schedule (() => onCompletedCallback (false), this.Latency); }
public override void EvictReceive(CoherentCacheNode source, uint addr, bool isWriteback, Action<bool> onReceiveReplyCallback) { this.Stat.Accesses++; this.Stat.Writes++; this.Schedule (() => onReceiveReplyCallback (false), this.Latency); }
public void UnsetSharer(CoherentCacheNode node) { Debug.Assert (node != null); if (this.Sharers.Contains (node)) { this.Sharers.Remove (node); } }
public virtual void EvictReceive(CoherentCacheNode source, uint addr, bool isWriteback, Action<bool> onReceiveReplyCallback) { throw new NotImplementedException (); }
public override void WriteRequest(CoherentCacheNode target, uint addr, Action<bool> onCompletedCallback) { this.Schedule (() => target.WriteRequestReceive (this, addr, onCompletedCallback), 2); }
public virtual void Invalidate(CoherentCacheNode except, uint @set, uint way, Action onCompletedCallback) { throw new NotImplementedException (); }
public override void WriteRequestReceive(CoherentCacheNode source, uint addr, Action<bool> onCompletedCallback) { this.FindAndLock (addr, this.Next == source, false, false, (hasError, @set, way, state, tag, dirLock) => { if (!hasError) { this.Invalidate (source, @set, way, () => { if (source.Next == this) { if (state == MESIState.Modified || state == MESIState.Exclusive) { this.WriteRequestUpdownFinish (source, false, @set, way, tag, state, dirLock, onCompletedCallback); } else { this.WriteRequest (this.Next, tag, hasError1 => { this.WriteRequestUpdownFinish (source, hasError1, @set, way, tag, state, dirLock, onCompletedCallback); }); } } else { this.Cache.SetLine (@set, way, 0, MESIState.Invalid); dirLock.Unlock (); this.Schedule (() => onCompletedCallback (false), 2); } }); } else { this.Schedule (() => onCompletedCallback (true), 2); } }); }
public virtual void WriteRequestReceive(CoherentCacheNode source, uint addr, Action<bool> onCompletedCallback) { throw new NotImplementedException (); }
public bool IsSharer(CoherentCacheNode node) { return this.Sharers.Contains (node); }