Ask HN: Can someone make a CAS just checking last bit on x86/ARM please?

4 pointsposted 17 days ago
by goofy_lemur

Item id: 46703768

3 Comments

Normal_gaussian

17 days ago

You're going to have to give a much clearer set of examples and justifications. I've had to CAS on bit masks, but not enough that it would make sense to introduce a new operation for it. I just CAS and spin if it fails and the bitmask is still valid.

goofy_lemur

17 days ago

all right, I am doing a sort of a copy-on-write thing here. So the idea is that I only want to update the pointer if the record it points to is "unlocked"

charleslmunger

17 days ago

What hardware are you running on where the cost of a relaxed 64 bit load and a branch is significant compared to a (possibly contended) cas?

You could always use ldset on arm for this.