If TSO is not consistent with SC, can we assume that PC will also not be consistent?
chenboy
@tarabyte true. Because PC is more relaxed than TSO.
tarabyte
Thanks, @chenboy.
ggm8
If we assume sequential consistency in program 4, is it actually the case that we cannot print 1, 0 either? Since if we print 1 in either case, the other variable will be 1 as well. So the only possible outputs are 1, 1 and 0, 1 - where there are 2 possible ways of printing 0, 1?
holard
Where are the results of execution listed?
haoala
Results of sequentially-consistent execution
Program 1: 1
Program 2: (0,0), (1,1) or (0,1)
Program 3: 1
Program 4: (0,1) or (1,1)
ggm8
@haoala Can you explain how you get (1,0) for Program 4?
SR_94
@ggm8 (1,0) arises when thread 2 writes to B and then prints out A as 0, thus thread 1 hasn't executed any of it's instructions yet. Now thread 1 writes 1 to A and prints B as 1.
Thus, thread output is (1,0) => thread 1 printed a 1 for B and thread 2 printed a 0 for A.
apk
@ggm8 Think of it not in the sense that what's printed is 1 then 0, but that (1,0) means thread1 printed 1, thread 2 printed 0 (thread 2 prints first)
ggm8
@SR_94 @apk Oh OK, I guess I wasn't thinking of it like that since only 1 thread does the printing in the other programs. Thanks for clarifying!
SR_94
@ggm8 Yeah, a 1 cannot be printed by thread 1 followed by a 0 by thread 2 since that would imply that thread 1 prints a 1 for B (therefore A = 1 now). So a 0 cannot be printed for A by thread 2 from that point on.
But thread 2 can print a 0 for A followed by thread 1 printing a 1 for B.
haoala
@ggm8, no, you're right. I made a mistake. Edited the original post to fix this.
cluo1
In program 3, Processor Consistency(PC) can print 0 when A = 1 has been propagated to thread 2 but not thread 3.
nemo
1st Case - Only 1 can get printed.
2nd case - 0,0 ; 1,1; 0,1 can get printed. (1,0 cannot be printed as W->W is not relaxed)
3rd case - Only 1 can get printed in SC. TSO - only 1 can get printed as it has seen B=1 which means that A=1 was seen by P2 (thus by P3 too as all processors see writes at the same time). PC - 0 can get printed as write to A might only be seen by P2 and not P3 (has seen write to B though).
4th case - Under SC, 0,1; 1,1 can get printed. In TSO and PC, 0,0; 1,0 can also get printed because of W->R relaxation.
haoala
@nemo. How can 1,0 be printed under SC for program 4? If the first thing printed is a 1, that means that the other variable has also been set to 1 and will print as 1.
nemo
@haoala, you are right! Updated the comment.
paracon
Would it be wrong to conclude that in a 2 processor system, TSO and PC have the same set of results?
RomanArena
I think that if there are only two processors, TSO and PC will have the same set of results.Since if A processor writes "X = 1",(X = 0 initially) the other processor B will read X depending whether it has received the message about the write. So there will no be difference between the TSO and PC results.
1_1
What can be printed in a SC version of each program:
keep in mind, for TSO and PC< only relaxing reads after writes. writes cannot be reordered
Program 1 "1". If write to flag is observed, write to A must have been observed.
If TSO is not consistent with SC, can we assume that PC will also not be consistent?
@tarabyte true. Because PC is more relaxed than TSO.
Thanks, @chenboy.
If we assume sequential consistency in program 4, is it actually the case that we cannot print 1, 0 either? Since if we print 1 in either case, the other variable will be 1 as well. So the only possible outputs are 1, 1 and 0, 1 - where there are 2 possible ways of printing 0, 1?
Where are the results of execution listed?
Results of sequentially-consistent execution Program 1: 1 Program 2: (0,0), (1,1) or (0,1) Program 3: 1 Program 4: (0,1) or (1,1)
@haoala Can you explain how you get (1,0) for Program 4?
@ggm8 (1,0) arises when thread 2 writes to B and then prints out A as 0, thus thread 1 hasn't executed any of it's instructions yet. Now thread 1 writes 1 to A and prints B as 1. Thus, thread output is (1,0) => thread 1 printed a 1 for B and thread 2 printed a 0 for A.
@ggm8 Think of it not in the sense that what's printed is 1 then 0, but that (1,0) means thread1 printed 1, thread 2 printed 0 (thread 2 prints first)
@SR_94 @apk Oh OK, I guess I wasn't thinking of it like that since only 1 thread does the printing in the other programs. Thanks for clarifying!
@ggm8 Yeah, a 1 cannot be printed by thread 1 followed by a 0 by thread 2 since that would imply that thread 1 prints a 1 for B (therefore A = 1 now). So a 0 cannot be printed for A by thread 2 from that point on. But thread 2 can print a 0 for A followed by thread 1 printing a 1 for B.
@ggm8, no, you're right. I made a mistake. Edited the original post to fix this.
In program 3, Processor Consistency(PC) can print 0 when A = 1 has been propagated to thread 2 but not thread 3.
@nemo. How can 1,0 be printed under SC for program 4? If the first thing printed is a 1, that means that the other variable has also been set to 1 and will print as 1.
@haoala, you are right! Updated the comment.
Would it be wrong to conclude that in a 2 processor system, TSO and PC have the same set of results?
I think that if there are only two processors, TSO and PC will have the same set of results.Since if A processor writes "X = 1",(X = 0 initially) the other processor B will read X depending whether it has received the message about the write. So there will no be difference between the TSO and PC results.
What can be printed in a SC version of each program:
keep in mind, for TSO and PC< only relaxing reads after writes. writes cannot be reordered
Program 1 "1". If write to flag is observed, write to A must have been observed.
Program 2 "0" "0". "1" "1". "0" "1".
Program 3 "1"
Program 4 "1" "1". "0" "1"