?

Log in

 

Hardware independent (sort of) compare and swap? - Advanced C++ Community

About Hardware independent (sort of) compare and swap?

Previous Entry Hardware independent (sort of) compare and swap? Dec. 24th, 2007 @ 10:13 am Next Entry
Is anyone aware of an existing free-as-in-beer codebase that provides an abstraction for compare-and-swap across common hardware types?

I am writing a fairly simple lock-free buffer type and would like to avoid doing the assembler myself. The platforms which I have an immediate interest in supporting are x86 and SPARC v9: nothing exotic.

I've done some hunting and pleasingly it looks like these atomic ops are quite likely to go into the C++ standard at some point (in C++0F or whatever), however I can't find anything concrete in terms of an implementation yet.

Leave a comment
[User Picture Icon]
From:omnifarious
Date:December 23rd, 2007 11:44 pm (UTC)
(Link)

I believe that Boost has atomic operations implemented for several platforms.

[User Picture Icon]
From:ataxi
Date:December 23rd, 2007 11:59 pm (UTC)
(Link)
Hey, you're right. The compare and swap calls are in detail/interlocked.hpp, for anyone who's interested.
[User Picture Icon]
From:ataxi
Date:December 24th, 2007 12:03 am (UTC)
(Link)
Hmm, except they may not include a SPARC alternative. Mm.
[User Picture Icon]
From:hub_
Date:December 24th, 2007 01:48 am (UTC)
(Link)
time to contribute it :-)
[User Picture Icon]
From:omnifarious
Date:December 24th, 2007 04:00 am (UTC)
(Link)

I would expect that both Linux and Solaris on the Sparc have a way that's likely somewhat cross-platform in their header files. You could make Boost work with that and contribute it. :-)

(Leave a comment)
Top of Page Powered by LiveJournal.com