Exemplo n.º 1
0
        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);
            }
        }
Exemplo n.º 2
0
        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);
            }
        }
Exemplo n.º 3
0
 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);
     }
 }
Exemplo n.º 4
0
        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);
                    }
                });
            }
        }
Exemplo n.º 5
0
        public void SetSharer(CoherentCacheNode node)
        {
            Debug.Assert (node != null);

            if (!this.Sharers.Contains (node)) {
                this.Sharers.Add (node);
            }
        }
Exemplo n.º 6
0
 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);
 }
Exemplo n.º 7
0
 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);
         }
     });
 }
Exemplo n.º 8
0
 public virtual void ReadRequest(CoherentCacheNode target, uint addr, Action<bool, bool> onCompletedCallback)
 {
     throw new NotImplementedException ();
 }
Exemplo n.º 9
0
 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);
         }
     });
 }
Exemplo n.º 10
0
        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 ();
            }
        }
Exemplo n.º 11
0
        public override void WriteRequestReceive(CoherentCacheNode source, uint addr, Action<bool> onCompletedCallback)
        {
            this.Stat.Accesses++;
            this.Stat.Writes++;

            this.Schedule (() => onCompletedCallback (false), this.Latency);
        }
Exemplo n.º 12
0
        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);
        }
Exemplo n.º 13
0
        public void UnsetSharer(CoherentCacheNode node)
        {
            Debug.Assert (node != null);

            if (this.Sharers.Contains (node)) {
                this.Sharers.Remove (node);
            }
        }
Exemplo n.º 14
0
 public virtual void EvictReceive(CoherentCacheNode source, uint addr, bool isWriteback, Action<bool> onReceiveReplyCallback)
 {
     throw new NotImplementedException ();
 }
Exemplo n.º 15
0
 public override void WriteRequest(CoherentCacheNode target, uint addr, Action<bool> onCompletedCallback)
 {
     this.Schedule (() => target.WriteRequestReceive (this, addr, onCompletedCallback), 2);
 }
Exemplo n.º 16
0
 public virtual void Invalidate(CoherentCacheNode except, uint @set, uint way, Action onCompletedCallback)
 {
     throw new NotImplementedException ();
 }
Exemplo n.º 17
0
 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);
         }
     });
 }
Exemplo n.º 18
0
 public virtual void WriteRequestReceive(CoherentCacheNode source, uint addr, Action<bool> onCompletedCallback)
 {
     throw new NotImplementedException ();
 }
Exemplo n.º 19
0
 public bool IsSharer(CoherentCacheNode node)
 {
     return this.Sharers.Contains (node);
 }