Hi, I'm struggling to understand how would the following two processes would be processed according to Causal Consistency Model...

Initially x=y=0

Process A
x = 1
if ( y = 0) z++

Process B
y = 1
if (x = 0) z++

I would appreciate if someone could reply by giving the step by step analysis of the processing. Thx

Maybe this will help: http://en.wikipedia.org/wiki/Causal_consistency

One point, unrelated to your causal linkage, is that your conditional statements of if (x = 0) and if (y = 0) should more appropriately be if (x == 0) and if (y == 0) so that one can distinguish between an assignment and a boolean comparison.

So, as for your question, the end value for Z is indeterminate since either process may assign x or y in any order, and at any time. IE, it could be that Z ends up with a value of 0 or 1. Consider possible steps:

1. A assigns 1 to x
2. B assigns 1 to y
3. A tests and finds y != 0 - no z increment results
4. B tests and finds x != 0 - no z increment results

end: z == 0 (you can switch order of process operations and get same z result)

or

1. A assigns 1 to x
2. A tests y and finds y == 0 - z increment results
3. B assigns 1 to y
4. B tests x and finds x != 0 - no increment results

end: z == 1 (you can switch order of A and B operations and get same z result)

So, z is causally linked to the values of x and y via the order they are set and read.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.