|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectavrora.sim.clock.Synchronizer
avrora.sim.clock.IntervalSynchronizer
The IntervalSynchronizer class implements a global timer among multiple simulators by inserting
periodic events into the queue of each simulator.
| Nested Class Summary | |
protected class |
IntervalSynchronizer.SynchEvent
The SynchEvent class represents an event that is inserted into the event
queue of each simulator at the same global time. |
| Field Summary | |
protected Simulator.Event |
action
|
protected java.lang.Object |
condition
|
protected int |
goal
|
protected int |
meet_count
|
protected long |
period
period is the number of cycles on a member local clock per cycle on the global clock. |
protected java.util.HashMap |
threadMap
|
protected int |
wait_count
|
protected avrora.sim.clock.IntervalSynchronizer.WaitSlot |
waitSlotList
|
| Constructor Summary | |
IntervalSynchronizer(long p,
Simulator.Event a)
The constructor for the IntervalSynchronizer class creates a new synchronizer
with the specified period, that will fire the specified event each time all threads meet at
a synchronization point. |
|
| Method Summary | |
void |
addNode(Simulation.Node t)
The addNode() method adds a node to this synchronization group.
|
void |
adjustPeriod(long nperiod)
The adjustPeriod() method can be used to adjust the period of synchronization
while the simulation is executing. |
protected avrora.sim.clock.IntervalSynchronizer.WaitSlot |
checkWaiters()
|
protected avrora.sim.clock.IntervalSynchronizer.WaitSlot |
insertWaiter(IntervalSynchronizer.SynchEvent event,
long time)
|
void |
join()
The join() method will block the caller until all of the threads in
this synchronization interval have terminated, either through stop()
being called, or terminating normally such as through a timeout. |
void |
pause()
The pause() method temporarily pauses the simulation. |
void |
removeNode(Simulation.Node t)
The removeNode() method removes a node from this synchronization
group, and wakes any nodes that might be waiting on it. |
protected boolean |
signalOthers()
The signalOthers() method is used to check whether the thread that has just arrived
should signal other threads to continue. |
void |
start()
The start() method starts the threads executing, and the synchronizer
will add whatever synchronization to their execution that is necessary to preserve
the global timing properties of simulation. |
protected boolean |
stillWaiting(avrora.sim.clock.IntervalSynchronizer.WaitSlot w)
|
void |
stop()
The stop() method will terminate all the simulation threads. |
void |
synch(long globalTime)
The synch() method will pause all of the nodes at the same global time.
|
void |
waitForNeighbors(long time)
The waitForNeighbors() method is called from within the execution
of a node when that node needs to wait for its neighbors to catch up to it
in execution time. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
protected long period
period is the number of cycles on a member local clock per cycle on the global clock. Some
re-coding must be done if microcontrollers running at difference speeds are to be accurately
simulated.
protected final java.util.HashMap threadMap
protected final Simulator.Event action
protected final java.lang.Object condition
protected int goal
protected int meet_count
protected int wait_count
protected avrora.sim.clock.IntervalSynchronizer.WaitSlot waitSlotList
| Constructor Detail |
public IntervalSynchronizer(long p,
Simulator.Event a)
IntervalSynchronizer class creates a new synchronizer
with the specified period, that will fire the specified event each time all threads meet at
a synchronization point.
p - the period in clock cycles which to synchronize the threadsa - the event to fire each time all threads meet at a synchronization point| Method Detail |
protected boolean signalOthers()
signalOthers() method is used to check whether the thread that has just arrived
should signal other threads to continue.
public void start()
start() method starts the threads executing, and the synchronizer
will add whatever synchronization to their execution that is necessary to preserve
the global timing properties of simulation.
start in class Synchronizer
public void join()
throws java.lang.InterruptedException
join() method will block the caller until all of the threads in
this synchronization interval have terminated, either through stop()
being called, or terminating normally such as through a timeout.
join in class Synchronizerjava.lang.InterruptedExceptionpublic void stop()
stop() method will terminate all the simulation threads. It is
not guaranteed to stop all the simulation threads at the same global time.
stop in class Synchronizerpublic void pause()
pause() method temporarily pauses the simulation. The nodes are
not guaranteed to stop at the same global time. This method will return when all
threads in the simulation have been paused and will no longer make progress until
the start() method is called again.
pause in class Synchronizerpublic void synch(long globalTime)
synch() method will pause all of the nodes at the same global time.
This method can only be called when the simulation is paused. It will run all threads
forward until the global time specified and pause them.
synch in class SynchronizerglobalTime - the global time in clock cycles to run all threads ahead topublic void addNode(Simulation.Node t)
addNode() method adds a node to this synchronization group.
This method should only be called before the start() method is
called.
addNode in class Synchronizert - the simulator representing the node to add to this grouppublic void removeNode(Simulation.Node t)
removeNode() method removes a node from this synchronization
group, and wakes any nodes that might be waiting on it.
removeNode in class Synchronizert - the simulator thread to remove from this synchronization grouppublic void waitForNeighbors(long time)
waitForNeighbors() method is called from within the execution
of a node when that node needs to wait for its neighbors to catch up to it
in execution time. The node will be blocked until the other nodes in other
threads catch up in global time.
waitForNeighbors in class Synchronizer
protected avrora.sim.clock.IntervalSynchronizer.WaitSlot insertWaiter(IntervalSynchronizer.SynchEvent event,
long time)
protected avrora.sim.clock.IntervalSynchronizer.WaitSlot checkWaiters()
protected boolean stillWaiting(avrora.sim.clock.IntervalSynchronizer.WaitSlot w)
public void adjustPeriod(long nperiod)
adjustPeriod() method can be used to adjust the period of synchronization
while the simulation is executing. This is useful for adaptive types of synchronization,
for example when the latency between beginning the first transmission and reception is larger
than subsequent transmissions (e.g. implementing partial preamble loss).
Care should be taken when calling this method! It should only be called at times when the
simulation is guaranteed to be stopped at the same global time; i.e. either at a meet
point or while it has been pause()'d and synch()'d.
nperiod - the new period in cycles
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||