added test for m_running in ScheduleRealNow
authorCraig Dowell <craigdo@ee.washington.edu>
Fri, 10 Oct 2008 21:01:50 -0700
changeset 3800 804beebf1ba5
parent 3799 ceea04d07e60
child 3801 dc1f5e534e56
added test for m_running in ScheduleRealNow
samples/main-test-sync.cc
src/simulator/realtime-simulator-impl.cc
--- a/samples/main-test-sync.cc	Fri Oct 10 16:43:43 2008 -0700
+++ b/samples/main-test-sync.cc	Fri Oct 10 21:01:50 2008 -0700
@@ -126,9 +126,9 @@
   FakeNetDevice fnd;
 
   // 
-  // Make sure ScheduleNow works when the system isn't running
+  // Make sure ScheduleRealNow works when the system isn't running
   //
-  Simulator::ScheduleNow(&first_function);
+  RealtimeSimulatorExtension::ScheduleRealNow(&first_function);
 
   // 
   // drive the progression of m_currentTs at a ten millisecond rate
--- a/src/simulator/realtime-simulator-impl.cc	Fri Oct 10 16:43:43 2008 -0700
+++ b/src/simulator/realtime-simulator-impl.cc	Fri Oct 10 21:01:50 2008 -0700
@@ -657,7 +657,11 @@
   {
     CriticalSection cs (m_mutex);
 
-    uint64_t ts = m_synchronizer->GetCurrentRealtime ();
+    //
+    // If the simulator is running, we're pacing and have a meaningful 
+    // realtime clock.  If we're not, then m_currentTs is were we stopped.
+    // 
+    uint64_t ts = m_running ? m_synchronizer->GetCurrentRealtime () : m_currentTs;
     NS_ASSERT_MSG (ts >= m_currentTs, "RealtimeSimulatorImpl::ScheduleRealNow(): schedule for time < m_currentTs");
     id = EventId (event, ts, m_uid);
     m_uid++;