VDM-10 Language Manual
VDM-10 Language Manual
VDM-10 Language Manual
You also want an ePaper? Increase the reach of your titles
YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.
Chapter 15. Synchronization Constraints (<strong>VDM</strong>++ and <strong>VDM</strong>-RT)<br />
Constraints for safe execution of the operations Push and Pop in a stack object can be<br />
expressed using an object state guard as:<br />
✞<br />
per Push => length < maxsize;<br />
per Pop => length > 0<br />
✡✝<br />
where maxsize and length are instance variables of the stack object.<br />
It is often possible to express such constraints as a consequence of the history, for example<br />
the empty state of the stack:<br />
✞<br />
✡✝<br />
length = 0 #fin(Push) = #fin(Pop)<br />
However, the size is a property which is better regarded as a property of the particular stack<br />
instance, and in such cases it is more elegant to use available instance variables which store<br />
the effects of history.<br />
✆<br />
✆<br />
15.1.3 Queue condition guards<br />
Semantics: A queue condition guard acts on requests waiting in the queues for the execution of<br />
the operations. This requires use of a third history function #req such that #req(A) counts<br />
the number of messages which have been received by the object requesting execution of operation<br />
A. Again it is useful to introduce the function #waiting such that: #waiting(A)<br />
= #req(A) - #act(A), which counts the number of items in the queue.<br />
Examples: Once again, with the web server we can only activate the ServerBusy operation if<br />
<strong>10</strong>0 or more connections are waiting:<br />
✞<br />
per ServerBusy => #waiting(RetrieveURL) +<br />
#waiting(ExecuteCGI) >= <strong>10</strong>0;<br />
✡✝<br />
The most important use of such expressions containing queue state functions is for expressing<br />
priority between operations. The protocol specified by:<br />
✞<br />
per B => #waiting(A) = 0<br />
✡✝<br />
gives priority to waiting requests for activation of A. There are, however, many other situations<br />
when operation dispatch depends on the state of waiting requests. Full description<br />
of the queuing requirements to allow specification of operation selection based on request<br />
arrival times or to describe ‘shortest job next’ behaviour will be a future development.<br />
141<br />
✆<br />
✆