Next: Event Semantics
Up: DISCUSSION
Previous: Logic Clock
Within the cocavm, there could be multiple threads
of execution.
It is necessary to have some synchronization mechanism
between concurrent threads.
For this purpose, operators of the internal database
are atomic and synchronized.
And we further introduce a special symbol ``@''
as syntactical sugar to define atomic predicates and sequences.
An atomic sequence is analyzed before execution.
All the database functors (or relations) involved in such a sequence
will be locked when the critical section is entered.
The lock is released when the sequence succeeds or is failed.
A thread blocks if it can not obtain the lock.
To prevent deadlocks, all the involved functors must be locked
or none.
An atomic sequence corresponds to the concept of transaction.
To support transactions in the internal database,
we would have to support rollback, i.e.,
when one predicate in the atomic sequence fails,
the effects of the whole transaction must be undone.
This is not hard to support though. For example, we can
analyze the sequence and make a backup copy of those functors that
could be affected. Once an operation fails, we can overwrite
the original copy with the backup copy. If the whole transaction
succeeds, we simply throw away the backup copy.
Next: Event Semantics
Up: DISCUSSION
Previous: Logic Clock
Du Li
8/25/1999