URL: <http://savannah.cern.ch/bugs/?99130> Summary: atomicity of XrdSysAtomics Project: XROOTD Submitted by: gadde Submitted on: 2012-11-28 14:59 Report Type: Bug Priority: 5 - Normal Severity: 3 - Normal Status: None Privacy: Public Assigned to: None Originator Email: Open/Closed: Open Discussion Lock: Any Fixed by commit(s): _______________________________________________________ Details: Hello in XrdSysAtomics.hh, some macros are defined when the compiler have atomics. Among these macros are the two following ones: #define AtomicDTZ(x) if (!(__sync_fetch_and_sub(&x, 1))) AtomicFAZ(x) #define AtomicISM(x, y) if (AtomicGet(y) <= AtomicInc(x)) AtomicCAS(y, y, x) To my understanding, these macros are not atomic. They can be interrupted by the scheduling of the threads and the values x or y can change before the conditional instruction is executed. for instance: assume the intial state is x=1 y=1 a call to AtomicISM(x, y) by thread 1 can be interrupted this way by thread 2 thread 1 -> compute that AtomicGet(y) <= AtomicInc(x) is true thread 2 -> set x to -1 thread 1 -> set y to -1 because of AtomicCAS(y, y, x) final state x=-1 y=-1 if it was atomic, the expected final state would be x=-1 y=2 There are of course, other ways to interefere with this macro and make it non atomic. Maybe, I miss a point. Cheers _______________________________________________________ Reply to this item at: <http://savannah.cern.ch/bugs/?99130> _______________________________________________ Message sent via/by LCG Savannah http://savannah.cern.ch/ ######################################################################## Use REPLY-ALL to reply to list To unsubscribe from the XROOTD-DEV list, click the following link: https://listserv.slac.stanford.edu/cgi-bin/wa?SUBED1=XROOTD-DEV&A=1