Previous | Next --- Slide 20 of 90
Back to Lecture Thumbnails
wzz

We care about memory coherence because when we write a multiprocess program as a programmer, we expect each process's instruction stream to behave consistent with sequential execution. While we understand that a compiler / hardware may switch the order of execution of independent statements, on a single-process machine we have the guarantee that such reorderings do not affect program output. On multi-process machines, however, reorderings that do not change one process's behavior may end up affecting another process.

In the example about, if both processes are free to reorder their (locally) independent read and writes, we might get a result of "00", which is impossible if we enforce sequential consistency.

rosalg

Memory consistency and implementation synchronization is important because it ensures that information occurs in the order that we desire. If we want more speed, then we can forgo consistency/synchronization but need to be prepared to handle the asychronous nature.

jchen

"01" can be printed if instructions are executed in order 1, 2, 3, 4.

"10" cannot be printed because P0 has to be execute 1 before 2, and P1 needs to execute 3 before 4.

"11" can be printed in order of 1, 3, 2, 4

"00" cannot be printed because we would need 3 and 4 to execute first, but that would again violate program order.

jchen

*assuming sequential consistency, as wzz mentions above

Please log in to leave a comment.