swarm-support
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: getCurrentTime


From: glen e. p. ropella
Subject: Re: getCurrentTime
Date: Thu, 3 Apr 1997 08:50:22 -0700

Sven Thommesen writes:
 > Last time I complained, it was on account of an attempt to call
 > getCurrentTime() before the sim had started.
 > 
 > This time, it's calling getCurrentTime while the sim has been 
 > temporarily halted from the controlPanel (click on 'Stop')!
 > 
 > I have an object, this object has a probe, this probe has buttons,
 > these buttons send messages to other objects, these messages invoke
 > methods that call getCurrentTime(). If I click on such a button
 > while the sim is running, no problem. If I click 'Stop' and then one
 > of those buttons, ... (hold your breath) another COREDUMP!
 > 
 > Now, Glen, ... [expression of infinite pain here]
 > 
 > Yes, I do get the 'InvalidOperation' message you quoted.
 > And yes, on inspection I do see it says you can use this macro
 > only "under a running activity". But my sim IS running! I specifically
 > WANT to have these messages sent in-between sim periods.
 > 
 > Is this situation irremediable ?

No.  It shouldn't be irremediable.  First off, if you "Stop"
your simulation, then your simulation isn't running.  Normally,
I would say that this should be obvious; but, two things are
being confused: the unix process and the Swarm Activity.

If you want the "time" in the context of the unix process, then,
yes, it makes sense to query for that time while your simulation
is "Stopped".  The thing you will be querying is the unix operating
system.  And it will forever continue forward as long as you're
in a busy-wait loop over the Tk widgets.

Then the next level is a query for time, while the sim is "Stopped",
where the clock being queried is the master clock in the simulation.
This clock will not advance while the sim is "Stopped".  

But you have to DESIGNATE WHICH clock you're querying.  It simply
doesn't make any sense to have an "out-of-context" reference to time
when time is not passing.  The getCurrentTime() must have a running
Activity to query.  If no Activity is running, the macro will not
work.  You can query for time while the sim is "Stopped" by using the
message defined for any ScheduleActivity.  I.e. you have to designate
which activity you're querying.

So, anytime you expect to get the current time when there is NO
activity whose status is "Running", then you have to use the 
getCurrentTime message.  If there will always be an activity 
"Running" for a piece of code where you need absolute time, then
you may use the getCurrentTime() macro.

I guess I'm not explaining this very well.  To see the problem,
imagine you're an assembler instruction in a program.  And imagine
that the program control is elsewhere in the program.  Does it
make any sense for you to ask "what time is it?"  No.  The control
pointer is elsewhere and you're just a piece of data at this point.
When, and if, the control pointer passes over you, then and only
then does it make sense for you to ask what time it is.

Now, this is not the case for whatever engine is "controlling"
the control pointer.  For instance, if the process recieves an 
interrupt, it stops, but, the "controller" of the process can 
still ask THAT process what time it has.  But, it can't do this
without designating which process it is asking.

If that makes any better sense, then all you have to do is think
of the unix process (or the Tk Widgetry that's operating under 
that process) as the operating system and the various activities
as the various processes.

Am I doing any better, here?

glen

                  ==================================
   Swarm-Support is for discussion of the technical details of the day
   to day usage of Swarm.  For list administration needs (esp.
   [un]subscribing), please send a message to <address@hidden>
   with "help" in the body of the message.
                  ==================================


reply via email to

[Prev in Thread] Current Thread [Next in Thread]