Seems the wait just wasn't long enough, at about 4 yields onwards the results become consistent success, I've attached the file I did the experiments in, I even tried it under -O3 and no exits were encountered, so yes my method works, just needs a bit more wait time for extreme cases On Mon, 28 Feb 2022 at 08:48, Joakim Sindholt wrote: > > On Sun, 27 Feb 2022 23:32:47 +0000, Lee Shallis wrote: > > Yes, as I mentioned before, pauseCB is supposed to have it's pointer > > be changed by the developer, in other words you forgot to plugin a > > pthreads compatible call prior to your threads starting, considering > > you made that mistake I suppose it is a good thing I since switched to > > a non-redirectable pointer: > > How many times do you want to do this? > > zhasha@wirbelwind /home/zhasha ; gcc -D_GNU_SOURCE -lpthread buglock.c > zhasha@wirbelwind /home/zhasha ; ./a.out > var = 1, expected 0 > zhasha@wirbelwind /home/zhasha ; ./a.out > var = 1, expected 0 > zhasha@wirbelwind /home/zhasha ; ./a.out > var = 1, expected 0 > zhasha@wirbelwind /home/zhasha ; ./a.out > var = 1, expected 0 > zhasha@wirbelwind /home/zhasha ; ./a.out > var = 1, expected 0 > var = 2, expected 1 > zhasha@wirbelwind /home/zhasha ; ./a.out > var = 1, expected 0 > var = 2, expected 1