base: Transition CP annotate to use shared_ptr
[gem5.git] / src / sim / simulate.cc
index 78695688af6da947d34b24a15589895f6547388f..426c3e662b0cde4ae841c94cc27f507187af2a6b 100644 (file)
@@ -114,7 +114,7 @@ simulate(Tick num_cycles)
             fatal("Quantum for multi-eventq simulation not specified");
         }
 
-        quantum_event = new GlobalSyncEvent(simQuantum, simQuantum,
+        quantum_event = new GlobalSyncEvent(curTick() + simQuantum, simQuantum,
                             EventBase::Progress_Event_Pri, 0);
 
         inParallelMode = true;
@@ -198,6 +198,9 @@ doSimLoop(EventQueue *eventq)
         }
 
         if (async_event && testAndClearAsyncEvent()) {
+            // Take the event queue lock in case any of the service
+            // routines want to schedule new events.
+            std::lock_guard<EventQueue> lock(*eventq);
             async_event = false;
             if (async_statdump || async_statreset) {
                 Stats::schedStatEvent(async_statdump, async_statreset);
@@ -210,9 +213,8 @@ doSimLoop(EventQueue *eventq)
                 exitSimLoop("user interrupt received");
             }
 
-            if (async_io || async_alarm) {
+            if (async_io) {
                 async_io = false;
-                async_alarm = false;
                 pollQueue.service();
             }