Previous | Next --- Slide 10 of 51
Back to Lecture Thumbnails
huehue

In this case, "hello world" and "world hello" cannot be printed. This is because when either "hello" or "world" is printed, we are setting a or b to 1, respectively. So when one string gets printed, we have already set the other variable to 1, so we can't enter the other conditional.

lol

@huehue Why can't "nothing" be printed? What if we have the sequence: A = 1, B = 1, if(B ..), if (A ..)

ZhuansunXt

@lol is correct, nothing printed can happen since instructions may be interleaved by arbitrary sequence, so when A and B are all set to 1 before any thread reach to if instruction, both print will not be executed.

efficiens

In other words, this program is not sequentially consistent.

Fantasy

@efficiens

I think memory "sequential consistent" is a concept for the architecture instead of the program. The same program can have different results under different consistency model.

For example, under sequential consistent model, this program can output "Hello" or "World" or nothing.

But under consistency model where we can reorder read before write, we can have output of "Hello World" and "World Hello" from this program.