merge with HEAD

This commit is contained in:
Mathieu Lacage
2012-03-23 08:38:57 +01:00
5 changed files with 5 additions and 80 deletions

View File

@@ -48,7 +48,6 @@ class FakeNetDevice
public:
FakeNetDevice ();
void Doit3 (void);
void Doit4 (void);
};
FakeNetDevice::FakeNetDevice ()
@@ -66,25 +65,11 @@ FakeNetDevice::Doit3 (void)
//
// Exercise the realtime relative now path
//
DynamicCast<RealtimeSimulatorImpl> (Simulator::GetImplementation ())->ScheduleRealtimeNow (MakeEvent (&inserted_function));
Simulator::ScheduleWithContext(0xffffffff, Seconds(0.0), MakeEvent (&inserted_function));
usleep (1000);
}
}
void
FakeNetDevice::Doit4 (void)
{
NS_LOG_FUNCTION_NOARGS ();
sleep (1);
for (uint32_t i = 0; i < 10000; ++i)
{
//
// Exercise the realtime relative schedule path
//
DynamicCast<RealtimeSimulatorImpl> (Simulator::GetImplementation ())->ScheduleRealtime (Seconds (0), MakeEvent (&inserted_function));
usleep (1000);
}
}
void
test (void)
@@ -97,7 +82,7 @@ test (void)
//
// Make sure ScheduleNow works when the system isn't running
//
DynamicCast<RealtimeSimulatorImpl> (Simulator::GetImplementation ())->ScheduleRealtimeNow (MakeEvent (&first_function));
Simulator::ScheduleWithContext(0xffffffff, Seconds(0.0), MakeEvent (&first_function));
//
// drive the progression of m_currentTs at a ten millisecond rate from the main thread
@@ -111,14 +96,9 @@ test (void)
MakeCallback (&FakeNetDevice::Doit3, &fnd));
st3->Start ();
Ptr<SystemThread> st4 = Create<SystemThread> (
MakeCallback (&FakeNetDevice::Doit4, &fnd));
st4->Start ();
Simulator::Stop (Seconds (15.0));
Simulator::Run ();
st3->Join ();
st4->Join ();
Simulator::Destroy ();
}

View File

@@ -271,26 +271,6 @@ EmuNetDevice::StartDevice (void)
NS_FATAL_ERROR ("EmuNetDevice::StartDevice(): Device is already started");
}
//
// We're going to need a pointer to the realtime simulator implementation.
// It's important to remember that access to that implementation may happen
// in a completely different thread than the simulator is running in (we're
// going to spin up that thread below). We are talking about multiple threads
// here, so it is very, very dangerous to do any kind of reference couning on
// a shared object that is unaware of what is happening. What we are going to
// do to address that is to get a reference to the realtime simulator here
// where we are running in the context of a running simulator scheduler --
// recall we did a Simulator::Schedule of this method above. We get the
// simulator implementation pointer in a single-threaded way and save the
// underlying raw pointer for use by the (other) read thread. We must not
// free this pointer or we may delete the simulator out from under us an
// everyone else. We assume that the simulator implementation cannot be
// replaced while the emu device is running and so will remain valid through
// the time during which the read thread is running.
//
Ptr<RealtimeSimulatorImpl> impl = DynamicCast<RealtimeSimulatorImpl> (Simulator::GetImplementation ());
m_rtImpl = GetPointer (impl);
//
// A similar story exists for the node ID. We can't just naively do a
// GetNode ()->GetId () since GetNode is going to give us a Ptr<Node> which
@@ -823,8 +803,8 @@ EmuNetDevice::ReadThread (void)
NS_LOG_INFO ("EmuNetDevice::EmuNetDevice(): Received packet on node " << m_nodeId);
NS_LOG_INFO ("EmuNetDevice::ReadThread(): Scheduling handler");
NS_ASSERT_MSG (m_rtImpl, "EmuNetDevice::ReadThread(): Realtime simulator implementation pointer not set");
m_rtImpl->ScheduleRealtimeNowWithContext (m_nodeId, MakeEvent (&EmuNetDevice::ForwardUp, this, buf, len));
Simulator::ScheduleWithContext (m_nodeId, Seconds (0.0),
MakeEvent (&EmuNetDevice::ForwardUp, this, buf, len));
buf = 0;
}
}

View File

@@ -33,7 +33,6 @@
#include "ns3/mac48-address.h"
#include "ns3/system-thread.h"
#include "ns3/system-mutex.h"
#include "ns3/realtime-simulator-impl.h"
namespace ns3 {
@@ -517,12 +516,6 @@ private:
*/
uint8_t *m_packetBuffer;
/**
* A copy of a raw pointer to the required real-time simulator implementation.
* Never free this pointer!
*/
RealtimeSimulatorImpl *m_rtImpl;
/*
* a copy of the node id so the read thread doesn't have to GetNode() in
* in order to find the node ID. Thread unsafe reference counting in

View File

@@ -214,26 +214,6 @@ TapBridge::StartTapDevice (void)
NS_ABORT_MSG_IF (m_sock != -1, "TapBridge::StartTapDevice(): Tap is already started");
//
// We're going to need a pointer to the realtime simulator implementation.
// It's important to remember that access to that implementation may happen
// in a completely different thread than the simulator is running in (we're
// going to spin up that thread below). We are talking about multiple threads
// here, so it is very, very dangerous to do any kind of reference couning on
// a shared object that is unaware of what is happening. What we are going to
// do to address that is to get a reference to the realtime simulator here
// where we are running in the context of a running simulator scheduler --
// recall we did a Simulator::Schedule of this method above. We get the
// simulator implementation pointer in a single-threaded way and save the
// underlying raw pointer for use by the (other) read thread. We must not
// free this pointer or we may delete the simulator out from under us an
// everyone else. We assume that the simulator implementation cannot be
// replaced while the tap bridge is running and so will remain valid through
// the time during which the read thread is running.
//
Ptr<RealtimeSimulatorImpl> impl = DynamicCast<RealtimeSimulatorImpl> (Simulator::GetImplementation ());
m_rtImpl = GetPointer (impl);
//
// A similar story exists for the node ID. We can't just naively do a
// GetNode ()->GetId () since GetNode is going to give us a Ptr<Node> which
@@ -684,8 +664,7 @@ TapBridge::ReadCallback (uint8_t *buf, ssize_t len)
NS_LOG_INFO ("TapBridge::ReadCallback(): Received packet on node " << m_nodeId);
NS_LOG_INFO ("TapBridge::ReadCallback(): Scheduling handler");
NS_ASSERT_MSG (m_rtImpl, "TapBridge::ReadCallback(): Realtime simulator implementation pointer not set");
m_rtImpl->ScheduleRealtimeNowWithContext (m_nodeId, MakeEvent (&TapBridge::ForwardToBridgedDevice, this, buf, len));
Simulator::ScheduleWithContext (m_nodeId, Seconds (0.0), MakeEvent (&TapBridge::ForwardToBridgedDevice, this, buf, len));
}
void

View File

@@ -32,7 +32,6 @@
#include "ns3/ptr.h"
#include "ns3/mac48-address.h"
#include "ns3/unix-fd-reader.h"
#include "ns3/realtime-simulator-impl.h"
namespace ns3 {
@@ -458,12 +457,6 @@ private:
*/
uint8_t *m_packetBuffer;
/**
* A copy of a raw pointer to the required real-time simulator implementation.
* Never free this pointer!
*/
RealtimeSimulatorImpl *m_rtImpl;
/*
* a copy of the node id so the read thread doesn't have to GetNode() in
* in order to find the node ID. Thread unsafe reference counting in