Adding attempt to mimic mutex code in atomic code