Check out the new USENIX Web site. next up previous
Next: Backtracking Up: DISCUSSION Previous: Messaging Policy

Some Predicates Revisited

  A number of database predicates can be easily defined by atomic sequences and atomic predicates, for example, update, collect, deleteAll, etc. While collect and deleteAll must be implemented assuming a total ordering of facts, update does not. Predicate update is implemented simply by an atomic sequence as follows.
\begin{smalltab}
\=update\=(OldT, NewT) :-\\ \\ gt \\ gt@(\=\\ \\ gt \\ gt \\ gt{\bf delete} OldT,\\ \\ gt \\ gt \\ gt{\bf add} NewT\\ \\ gt \\ gt).\end{smalltab}

The blocking database operators introduced above can be implemented with wait-for. For example, predicate ``querysync f(a, b)'' can be defined by the following. Operator deletesync can be defined similarly.
\begin{smalltab}
\={\bf query}\=$^{sync}$\space f(a, X) :-\\  \\ gt \\ gt{\bf qu...
 ...nc}$\space f(a, X) :-\\  \\ gt \\ gt{\bf wait-for}(add-f(a, X)).
 \end{smalltab}
However, when a fact say ``f(a, b)'' is added into the database, an event ``add-f(a, b)'' must be posted either by the user or by the runtime system.

The accept operator can also be elegantly defined in terms of wait-for as follows, where g is the name of a gate.
\begin{smalltab}
\=g ? (X, a) \= :-\\  \\ gt \\ gt {\bf wait-for}(g(X, a)).\\  \...
 ...g), X, a) :-\\  \\ gt \\ gt {\bf post-event}$^{async}$(g(X, a)).
 \end{smalltab}

Predicate wait-for also provides a possible means to implement locking and unlocking of database relations, as follows.
\begin{smalltab}
\=lock(O\=bject) :-\\ \\ gt \\ gt{\bf query} locked(Object),\\ ...
 ...ject), \\ \\ gt \\ gt{\bf post-event}$^{async}$(unlocked(Object)).\end{smalltab}
Once an ``unlocked(Object)'' event is posted, only one thread waiting for it is woken up nondeterministically to consider its wait-for predicate. So this definition guarantees that the lock not be grabbed by several threads at the same time.

Since those predicates can be specified, we do not really have to implement them.


next up previous
Next: Backtracking Up: DISCUSSION Previous: Messaging Policy
Du Li
8/25/1999