\end{vdm_al} Class used for concurrent VDM++ models. All threads should call the following operations:
- WaitRelative(t): makes the threadperiodicwith t = the period
- NotifyAll(): notified all threads sleeping in the wakeUpMap
- Awake(): puts the threadto sleep - will wakeup when t time units has passed
The step length with which the currentTime is incremented
\begin{vdm_al} values
public stepLength : nat = 1;
instancevariables
currentTime : nat := 0;
wakeUpMap : mapnattonat := {|->}; --syncWithTimeInc : set of nat := {}; --syncWithTimeIncCurrent : set of nat := {};
operations
\end{vdm_al}
WaitRelative: sleeps the calling threadfor'val'time units - relative to the currentTime
\begin{vdm_al}
\end{vdm_al}
NotifyAll: notifies all threads - waking up threads which wakeUpTime is up
\begin{vdm_al}
public NotifyAll : () ==> ()
NotifyAll() == let threadSet : setofnat = {th | th insetdom wakeUpMap & wakeUpMap(th) <= currentTime } in forall t inset threadSet do
NotifyThread(t);
\end{vdm_al}
NotifyAndIncTime: Must only be used by ONE thread - usually the Environment thread.
Increments the currentTime with stepLength time units, and notifies all threads.
\begin{vdm_al}
\end{vdm_al}
GetTime: Returns the currentTime.
\begin{vdm_al}
public GetTime : () ==> nat
GetTime() == return currentTime;
\end{vdm_al}
Awake: Used to sleep threads - will not wake up until threadidis removed from wakeUpMap
\begin{vdm_al}
public Awake: () ==> ()
Awake() == skip;
\end{vdm_al}
SyncWithTimeIncrement: Called by threads which need to finish their loop/operation before time can be increased.
YieldTimeIncrement is call when a threadis ready to a time increment.
Once a thread has call SyncWithTimeIncrement is must call YieldTimeIncrement eventually, otherwise time increment
will be prevented
\begin{vdm_al}
--public SyncWithTimeIncrement : () ==> () --SyncWithTimeIncrement() == --( -- syncWithTimeInc := syncWithTimeInc union {threadid}; --keep track of all -- syncWithTimeIncCurrent := syncWithTimeIncCurrent union {threadid}; --include in current sync round -- skip; --);
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung ist noch experimentell.