macro CAS(succes, current,old,new) begin
succes := FALSE;
if (current=old) then
current := new;
succes:=TRUE
end if;
end macro
(BTW, as far as I understand the PlusCal User manual, a macro is executed within the same step is it called. Therefore, it is atomic, right?)
If I use this macro to increment z atomically w/o locking I have the following code: