A more complete attempt to fix the clock skew.
authorGabe Black <gblack@eecs.umich.edu>
Fri, 27 Oct 2006 11:09:14 +0000 (07:09 -0400)
committerGabe Black <gblack@eecs.umich.edu>
Fri, 27 Oct 2006 11:09:14 +0000 (07:09 -0400)
--HG--
extra : convert_revision : b2d505de51fc5fcae5177b2a13140729474e249e

src/cpu/simple/atomic.cc

index b4ea4b216cdc51e9694b2925582258021e16ce57..a72f6361a8ad49bc3f22bfe27c13aba14f2dc6cf 100644 (file)
@@ -188,8 +188,11 @@ AtomicSimpleCPU::resume()
 
         changeState(SimObject::Running);
         if (thread->status() == ThreadContext::Active) {
-            if (!tickEvent.scheduled())
-                tickEvent.schedule(curTick);
+            if (!tickEvent.scheduled()) {
+                Tick nextTick = curTick + cycles(1) - 1;
+                nextTick -= (nextTick % (cycles(1)));
+                tickEvent.schedule(nextTick);
+            }
         }
     }
 }
@@ -217,7 +220,9 @@ AtomicSimpleCPU::takeOverFrom(BaseCPU *oldCPU)
         ThreadContext *tc = threadContexts[i];
         if (tc->status() == ThreadContext::Active && _status != Running) {
             _status = Running;
-            tickEvent.schedule(curTick);
+            Tick nextTick = curTick + cycles(1) - 1;
+            nextTick -= (nextTick % (cycles(1)));
+            tickEvent.schedule(nextTick);
             break;
         }
     }
@@ -237,7 +242,7 @@ AtomicSimpleCPU::activateContext(int thread_num, int delay)
     //Make sure ticks are still on multiples of cycles
     Tick nextTick = curTick + cycles(1) - 1;
     nextTick -= (nextTick % (cycles(1)));
-    tickEvent.schedule(curTick + cycles(delay));
+    tickEvent.schedule(nextTick);
     _status = Running;
 }