On Wed, 07 Jan 2009 10:47:03 -0500, redsea <[email protected]> wrote:

When I implement some high performance program in linux 32bit, 32bit atomic if often not sufficient, for example, If I want to hold a index & a timestamp to a atomic variable, 32bit is not enough, in 64bit environment, I can do that.

No you can't. On pretty much all 32-bit systems the double wide Compare and Swap operation is availible, which allows you to use the index + tag method to advoid the ABA problem. However, a decent number of 64-bit systems don't support this operation leaving the vast majority of lock-free algorithms high and dry. (While there are high order bits you could hide a tag in, kernel developers are already using them for OS stuff). Of course, if you're referring to indexing into an array, you can use two shorts, etc. on 32-bit machines for much the same effect.


Reply via email to