On May 23, 2016, at 4:20 PM, Martin Buchholz <[email protected]> wrote: > > As I said in a previous message, you can implement subword CAS using > fullword CAS in a loop. > > cas8bit(expect, update) { > for (;;) { > fullword = atomicRead32() > if ((fullword &0xff) != expect) return false; > if (cas32(fullword, (fullword & ~0xff) | update) return true; > } > }
Yes, that's the "artisanal" version I would reach for. It doesn't scale well if there is unrelated activity on nearby bytes. But, for that matter, "nearby" can mean "within 64 bytes", which is why we have @Contended for when we really need it. — John
