[Ns-developers] Proposed Simulator Changes
Mathieu Lacage
mathieu.lacage at sophia.inria.fr
Mon Oct 13 04:52:58 PDT 2008
On Sat, 2008-10-11 at 18:35 -0700, craigdo at ee.washington.edu wrote:
> > > Then you will get a system that attempts to pace the
> > simulation time (as
> > > defined completely be the non-real-time simulation
> > implementation) to an
> > > underlying real-time clock. This should be sufficient for
> > most people.
> > > Your familiar methods:
> > >
> > > Simulator::Schedule ()
> > > Simulator::ScheduleNow ()
> > > Simulator::Now ()
> >
> > 1) I see that ::RunOneEvent is not implemented in
> > RealtimeSimulatorImpl.
> > Is it not possible to implement it by a single call to
> > ProcessOneEvent ?
>
> It can be made to run, but what do you expect it to do? It certainly
> isn't
I expect it to do what it does already, that is, synchronize on the
wall-clock and execute one event. This has allowed me to run gustavo's
visualizer successfully, which, as far as I am concerned, is good-enough
for now. We can revisit that implementation later if someone complains
about it.
> > If you feel that the 'Real' keyword is not
> > sufficiently-explicit, 'Realtime' or 'WallClock' seem fine:
> >
> > class Simulator
> > {
> > static void ScheduleXXX (Time delay, ...);
> > static void ScheduleXXXNow (...);
> > static Time XXXNow (void);
> > };
> >
> > where XXX is one of Real, Realtime, RealTime, WallClock.
>
> I could be convinced that moving these methods back into Simulator
> would be
> okay if we plastered enough warning signs all over them. If you
> actually
Feel free to do so, but, please, make sure that no method documentation
is longer than 3 paragraphs.
> want to remove the multihread-safety from some simulator methods, and
> move some multithread-safe methods in, I would say that is a recipe
> for disaster.
I obviously am less concerned than you about this potential disaster but
if you really care about moving these new methods to a separate header,
I would like to suggest the following which is pretty close to what you
have right now:
0) simulator.h is documented to _not_ be thread-safe.
1) wallclock-simulator.h contains WallclockSimulator
2) defines:
class WallclockSimulator
{
static void ScheduleXXX (Time delay, ...);
static void ScheduleXXXNow (...);
static Time XXXNow (void);
};
3) WallclockSimulator _API_ is documented to be thread-safe
4) implement Simulator and WallclockSimulator in the same file,
simulator.cc
5) extend SimulatorImpl:
class SimulatorImpl
{
virtual void ScheduleXXX (Time delay, ...) = 0;
virtual void ScheduleXXXNow (...) = 0;
virtual Time XXXNow (void) const = 0;
};
6) implement (5) in default-simulator-impl.cc with NS_FATAL_ERROR and
file a bug about it: we want to eventually implement these correctly.
regards,
Mathieu
More information about the Ns-developers
mailing list