-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Synchronization Algebra #59
Comments
It seems to me SAs are pretty much conical PCMs, e.g. see the presentation in https://core.ac.uk/download/pdf/82434444.pdf |
Well, except the commutativity part : ) |
It sounds like you might want to keep some commutativity, arriving at some sort of a hybrid between PCM and a trace monoid (partial partially commutative monoid?) |
Currently, I'm not sure that commutativity applies to our setting. So let me try to explain why : ) In a relaxed memory theory, a common approach to define the semantics as a set of so-called execution graphs. Each execution graph consists of set of events The transitive closure of Now to the business! Back to the example in the beginning. How we can reconstruct it following the compositional semantics? Next, we take their composition
|
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:L
is a set of labels;\star
is a "fictional" asynchronous label (more about its purpose below);\bot
is 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 = \star
l * l' = \star ==> l = l' = \star
for alll
,l'
l * \bot = \bot
for 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 labelt
.Consider two singleton event structures:
E1 ::= { e1:a }
andE2 ::= { 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 thate1: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)
andP2 ::= read(x)
.Their denotations would be equal to the following event structures:
E1 ::= { e1:W(x,1) }
andE2 ::= { e2:R(x,\bot) }
.Next, we want the denotation of their parallel composition
P1 || P2
to beE1 || 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 = \bot
otherwise.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 dependencybetween 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)
, butR(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
Assume that the type
L
of labels has a distinguished\bot
inhabitant.Then we can encode
*
as a total operation.The drawback of this approach is that the
\bot
label cannot be usedas 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 like
forall 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
The text was updated successfully, but these errors were encountered: