Wait so it is apparently possible to construct a (lock-free) multiword CAS out of singleword ones?

Is this why GNU libatomic has a hard dependency on CAS primitives? :cirnothinking:

@koakuma without memory linear in the number of threads that could be involved?

@robryk But seems like the schemes I've read so far does involve a per-thread structure yes

@koakuma Actually, I think one can do with just one shared "buffer", at least in the world where you can fit a counter of operations in half of the CAS word -- while filling the buffer, which is composed of <prev version, word> pairs, you CAS its elements so that you start failing if there was an intervening update.

@robryk I wonder if a 2x32b CAS has enough space for the counter...

Follow

@koakuma btw an interesting special case is when this cas will never see conflicting updates (only possibly updates that have already been applied in the past). This special case is way simpler, but still has the counter overflow problem

@robryk Another thing that I'd like to know is how easy it is to conjure up a lockfree DWCAS out of singleword ones :cirnothinking:

With the constraint that allocating one time during thread startup is an acceptable thing but having to allocate in the middle of a thread run is a no-no...

@koakuma in all of these cases: how fine are you with lock-free unless scheduler has been extremely unfair (in which case it may block)?

@robryk Ideally I'd want something close to a native DWCAS (which I don't think have any fairness guarantee either?)

@robryk Though this is more of a curiosity thing don't take it too seriously lole

Sign in to participate in the conversation
Qoto Mastodon

QOTO: Question Others to Teach Ourselves
An inclusive, Academic Freedom, instance
All cultures welcome.
Hate speech and harassment strictly forbidden.