diff --git a/lectures/concurrency/index.html b/lectures/concurrency/index.html index ca0e459..99cd767 100644 --- a/lectures/concurrency/index.html +++ b/lectures/concurrency/index.html @@ -556,7 +556,8 @@
x
and y
-are initially 0.
+are initially 0. The idea is for Thread 2 to wait until Thread 1 finishes some work. It
+signals that it is done by setting the variable x
to 1:
Thread 1:
@@ -576,11 +577,12 @@ When is synchronization needed?Thread 2 could observe the update tox before the update to y .
The fact that Thread 1 assigned to y before
it assigned 1 to x does not matter! This behavior can and does happen frequently
-with modern hardware. When it happens is hardware-dependent, so that code that seems to work
-correctly on one processor (say, an Intel x86 processor) may fail to work on a machine using
-an ARM processor. This bizarre state of affairs shows that programming with
-concurrency can be highly counterintuitive, and that one must never rely on naive assumptions
-about the order of events.
+with modern hardware. When it happens is hardware-dependent, so that code that
+seems to work correctly on one processor (say, an Intel x86 processor) may fail
+to work on a machine using an ARM processor, which makes weaker guarantees.
+This bizarre state of affairs shows that programming with concurrency can be
+highly counterintuitive, and that it is easy to make bad assumptions about the
+order of events.
The most reliable way diff --git a/lectures/synchronization/index.html b/lectures/synchronization/index.html index 82913c1..4dd8477 100644 --- a/lectures/synchronization/index.html +++ b/lectures/synchronization/index.html @@ -124,6 +124,7 @@ Condition variablesGiven that synchronization is needed for threads to see each other's effects, is there a way to successfully implement the earlier example that broke due to weak memory consistency? +Recall that the idea was to have one thread wait until another one finished some updates: |