Things I've written that have amused other people, Episode 8

Raymond Chen

In a technical discussion, I opened a reply with

Bob’s paper which I haven’t yet read points out that…

Some people wrote to me to say that the’ve added this quote to their file in the hopes of being able to use it themselves someday.

For those who are curious, I found the technical discussion in question. It had to do with whether the following code is thread-safe:

// initial conditions
int x = 1, y = 0;
int *p = &x;
// Thread 1 executes this
y = 1;
MemoryBarrier();
p = &y;
// Thread 2 executes this
print *p;

Question: Can this code legitimately print 0?

Surprisingly, the answer is yes!

0 comments

Discussion is closed.

Feedback usabilla icon