![]() |
Section 7.1.4:
|
This abstract class defines a state component which is a set of every class sub-typing from this class. Note that SAME has to be an instantiated class, not an abstract one.
NOTE | See the important note about vdm state in the notes on vdm-sl usage in this specification. |
This pervasive abstract class is the synchronisation absrtaction from which all forms of synchronising mechanism must sub-type.
This feature provides a facility for a program using a class which sub-types from this abstraction to test if the thread applying it may acquire the lock concerned.
acquirable | ( |
tid : $REFERENCE | |
) : BOOL |
The pre-condition is vsacuously true since both arguments are not optional vdm types.
This post-condition is vacuously true since the operation is total.
This predicate returns true if and only if the lock may be acquired by the calling thread.
NOTE | This call is not atomic with any subsequent call of acquire. |
This feature enables an invoking thread to acquire the lock concerned. If necessary in order to do so the thread is suspended until the lock is free.
acquire | ( |
tid : $REFERENCE | |
) |
The argument is an actual run-time thread identity. This cannot be enforced by the language since it is provided by the run-time environment.
The lock has been successfully acquired by the calling thread.
This routine attempts to acquire the lock (self), blocking if it is not available. When the routine returns the lock has always been acquired.
The action of releasing the lock makes it available for other threads.
release | ( |
tid : $REFERENCE | |
) |
The argument is expected to be a run-time thread identity. This cannot be enforced by the language since it is externally provided at run-time.
The lock has been released for use by another thread.
This routine releases the lock self for use by other executing threads provided that the calling thread has previously acquired (and not yet released) the lock, otherwise no action is taken.
The following three features work together to provide locking facilities for the situation where a thread can continue doing other actions while waiting for a lock.
Whether or not the thread executing this call acquires the lock as a result of requesting it, it continues execution without pause. Acquirable above may be used to test if the lock was actually acquired.
request | ( |
tid : $REFERENCE | |
) |
The argument is expected to be a run-time thread identity. This cannot be enforced by the language since it is only available when executing.
Since the availability (or not) of this lock does not affect the post-execution state of the program, this post-condition is vacuously true.
This routine requests the lock (self). If the lock is available it is acquired. Execution continues whether or not the lock has been acquired.
If a lock request has been made and not satisfied, the application of this feature cancels the request. If the lock has been acquired then nothing is done, as is the case if no previous request has been made.
cancel_request | ( |
tid : $REFERENCE | |
) |
The argument is expected to be a run-time thread identity. This cannot be enforced by the language.
This definition makes use of a fictitious thread type for explanatory purposes. If the lock is not acquirable then some other thread has acquired it - or may do so.
If there is still an outstanding request for the lock then the request is cancelled. If either there is no request or the lock has been acquired then no action is taken.
This feature is provided to let a thread which has requested, but not acquired, the lock and has nothing else to do, to wait for it to become available.
wait_for | ( |
tid : $REFERENCE | |
) |
The argument is expected to be a run-time thread identity. This cannot be enforced by the language.
Since the lock is always held by the calling thread on exit, this post-condition is vacuously true.
This routine blocks the calling thread until the lock self which had been requested is acquired. It differs from the acquire feature in that if the lock had not been requested then execution of the thread does not block but continues.
![]() |
Language Index | ![]() |
Library Index | ![]() |
Section 7 Index |
Comments
or enquiries should be made to Keith Hopper. Page last modified: Monday, 22 May 2000. |
![]() |