I have tried to establish an invariant between two atomic counters in one thread while ensuring that this invariant was maintained during read on an other thread without using a mutex.
Nevertheless looking at the code, it appears that I just implemented some sort of locking algorithm using the two atomic counters (with the risk I just messed up).
Is it possible to share an invariant between threads without using a locking strategy?
EDIT: The term invariant may not be adequate.
Let say I have two variables a and b, at some point in the program execution a thread A set a and b to some distinct values, and after that I woukd like that if a thread B load the value a stored by A and then load b, the loaded value of b is the one stored by A and not a value stored later in b.