Previous | Next --- Slide 20 of 84
Back to Lecture Thumbnails
nassosterz

If X2 commits before X1 then it reads bar as [0,0]. If X2 commits after X1 then it reads bar as [9,7].

What we are interested is whether work inside X1 and X2 can be done in parallel.

michzrrr

Question about the usage of transactions, since in this case we have 2 possible outputs of our transactions, but I can't see how this would be the desired behavior, when we usually want things to be deterministic.

sirej

@michzrrr consider an implementation of atomic that uses locks. X1 and X2 would still have atomic sections and the nondeterminism you mention is still present. That is there regardless of if the atomix section is implemented with STM, HTM, or locks. One way to reconcile this is that with parallelism and multithreading, it is up to the operating system to schedule threads and this nondeterminism is present whether we like it or not. In cases where different threads share some common memory they can write to, this might be a counter for how many jobs they've completed, or a sum of values they've encountered, and the nondeterminism may not be present in the final value of this shared variable due to being able to reorder additions.

Please log in to leave a comment.