Previous | Next --- Slide 28 of 60
Back to Lecture Thumbnails
Abandon

Considering the aim of this program example, I think the third line of foo function should be *x++; instead of x++; since the argument of this program is a pointer.

koala

I agree @Abandon. While in Thread 1, x is an int, in Thread 2, x is passed in as int*. In Thread 2, we don't want to just increment a local copy of x in foo, but rather the x that is created in Thread 1.

Metalbird

The locks are used to preserve dependencies in the data, which prevents inconsistent states, but they do have a cost in slowing down the execution. On this slide, it is expressed how the primitives used to lock are also shared variables in this shared address space model.