kaist-cp / cs500

Moved to https://cp-git.kaist.ac.kr/jeehoon.kang/cs500
25 stars 7 forks source link

Have question in p18 of concurrent algorithm #67

Closed SeongJinAhn closed 5 years ago

SeongJinAhn commented 5 years ago

In p18 it is said that X.load(acquire) disallows hoisting of later instruction. But in p19 lock.swap(true,acquire) is written tosolve problem of spinlock rather than lock.load(true,acquire). Is it right? If then could you tell me the reason?

jeehoonkang commented 5 years ago

swap performs read and write at the same time. The acquire annotation in swap() also means it disallows hoisting of later instructions.

jeehoonkang commented 5 years ago

(Closing, as it seems @SeongJinAhn acknowledged my answer. Feel free to reopen it!)