Posts: 33 Location: North Brunswick, NJ Joined: 12.03.08
Posted on January 06 2011 03:50
At work, we're maintaining a multithreaded application and I need to use the atomic builtins available to the C compiler. I'm curious about the difference between __ATOMIC_INCREMENT_x and __ATOMIC_INCREMENT_x_RETRY. In particular, if I use the non-RETRY version, does it guarantee that the value will be incremented or does it retry some number of times and give up? I assume since there's no status return that it retries until successful.
The version without the retry count will always return after the increment is completed. If the atomic function is not possible, the application will hang at that funtion until such time as it can be completed. The retry version will attempt at least once (even if the retry number is 0) and return without updating the target should the retry limit be reached. In other words the call with the retry limit will give up after that number of retries.