-
Notifications
You must be signed in to change notification settings - Fork 1
Description
Synchronization algebra is a algebraic structure defined on the set of labels.
It determines pairs of events from parallel processes which should synchronize on parallel composition.
In [2] the S.A. is defined as tuple <L, \star, \bot, *> where:
Lis a set of labels;\staris a "fictional" asynchronous label (more about its purpose below);\botis undefined label, it's used to indicate when two labels cannot synchronize;*is a binary synchronization operation.
With the following axioms.
*is associate*is commutative\star * \star = \starl * l' = \star ==> l = l' = \starfor alll,l'l * \bot = \botfor alll
The paper [2] gives an example of S.A.
\star |
a |
!a |
t |
\bot |
|
\star |
\star |
a |
!a |
t |
\bot |
a |
a |
\bot |
t |
\bot |
\bot |
!a |
!a |
t |
\bot |
\bot |
\bot |
t |
t |
\bot |
\bot |
\bot |
\bot |
\bot |
\bot |
\bot |
\bot |
\bot |
\bot |
That is, the algebra consists of two complementary labels a and !a, which can synchronize into label t.
Consider two singleton event structures: E1 ::= { e1:a } and E2 ::= { e2:!a }
(with no conflicts and trivial causality, i.e. \emptyset |- e1 and \emptyset |- e2).
Then their parallel composition (according to [1]) will be
E1 || E2 ::= { (e1, \star):a, (\star, e2):!a, (e1, e2):t }
with trivial causality and conflict between events (e1, \star) & (e1, e2); and conflict between events (\star, e2) & (e1, e2).
In other words, an event (e1, e2) does not depend neither on (e1, \star) nor (\star, e2), and it is in conflict (cannot occur simultaneously) with both of them.
While the label \bot is used to indicate that two labels cannot synchronize (i.e. it encodes partiality of the synchronization operation), the label \star is used as dummy "idle" synchronization.
That is, since we have e1:a * e2:!a = (e1,e2):t, it is convinient to assume that e1:a * \star = (e1, \star):a, i.e. e1 "synchonizes" with distinguished fictional event \star.
Next, the paper [2] defines the "divides" relation (let's denote it as >>).
l1 >> l2 ::= \exists l3. l1 * l3 = l2.
This relation is proven to be transitive.
Now, giving this classical construction [1,2], we'll have to adjust it for our needs.
The most significant change that I want to propose is to get rid of commutativity, i.e. to make synchronization operation asymmetric. Thus we will be able to capture asymmetry between writes/reads to shared memory, or, more generally, an asymmetry between producers/consumers.
Let's consider the labels that we have in the relaxed shared memory concurrency semantics.
Label ::= W(x,v) | R(x,v)
That is, we have writes and reads, annotated by the memory location and value written/read.
It would be convenient to assume that there is a distinguished "undefined" value \bot.
We will use it to give the denotations to individual read instructions.
For example, consider two programs P1 ::= write(x, 1) and P2 ::= read(x).
Their denotations would be equal to the following event structures:
E1 ::= { e1:W(x,1) } and E2 ::= { e2:R(x,\bot) }.
Next, we want the denotation of their parallel composition P1 || P2 to be
E1 || E2 ::= { (e1,\star):W(x,1), (\star,e2):R(x,\bot), (e1,e2):R(x,1) }.
In order to achieve that, we need to define the synchronization algebra as follows:
W(x,a) * R(x,\bot) = R(x,a);l1 * l2 = \bototherwise.
Then we'll have that W(x,a) >> R(x,a) as expected.
However, an important departure from the classical theory,
is that in E1 || E2 we also want to add causality dependency
between the write and the synchronized read.
That is, we want (e1,e2):R(x,1) to causally depend on (e1,\star):W(x,1),
and at the same time the event (e1,e2):R(x,1) should be in conflict with (\star,e2):R(x,\bot).
That is why I propose to get rid of commutativity in synchronization algebra.
In other words, the W(x,a) * R(x,\bot) = R(x,a), but R(x,\bot) * W(x,a) = \bot.
My assumption is that this asymmetry will help us to capture the causality
between the write event (producer) and the read event (consumer).
Unresolved Questions
- How to better encode the partial synchronization operation?
-
Assume that the type
Lof labels has a distinguished\botinhabitant.
Then we can encode*as a total operation.
The drawback of this approach is that the\botlabel cannot be used
as the "actual" label of some event in the event structure.
That is, we will have to encode this as an additional axiom of the event structure,
i.e. something likeforall e, lab e != \bot.
It might be very inconvenient to work with this constraint,
as we'll have to make redundant case analysis every time we'll take a label of some event. -
Use the
option, i.e.* : L -> L -> option L.
All common drawbacks of this approach follow immediately. -
Use an encoding similar to the one from FCSL-PCM project https://github.com/imdea-software/fcsl-pcm.
Here we need help from @anton-trunov to explain to us how it works
and what are the pros and cons of this approach.
[1] Winskel G. Event structures //Advanced Course on Petri Nets. – Springer, Berlin, Heidelberg, 1986. – С. 325-392.
link
[2] Winskel G. Event structure semantics for CCS and related languages //International Colloquium on Automata, Languages, and Programming. – Springer, Berlin, Heidelberg, 1982. – С. 561-576.
link