\end{vdm_al}
Modified by Johanne U. Jensen toactas a thread barrier.
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
TimeStamp(nat1 barrierCount);
WaitRelative // blocks
WaitAbsolute // blocks
NotifyThread // Non blocking
GetTime // Non blocking
public WaitAbsolute : nat ==> ()
WaitAbsolute(val) == (
AddToWakeUpMap(threadid, val); -- Last to enter the barrier notifies the rest.
BarrierReached(); -- Wait till time is up
Awake();
);
BarrierReached : () ==> ()
BarrierReached() ==
( while (carddom wakeUpMap = barrierCount) do
(
currentTime := currentTime + stepLength; let threadSet : setofnat = {th | th insetdom wakeUpMap
& wakeUpMap(th) <> niland wakeUpMap(th) <= currentTime } in forall t inset threadSet do
wakeUpMap := {t} <-: wakeUpMap;
);
) postforall x insetrng wakeUpMap & x = nilor x >= currentTime;
AddToWakeUpMap : nat * [nat] ==> ()
AddToWakeUpMap(tId, val) ==
wakeUpMap := wakeUpMap ++ { tId |-> val };
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.