|
|
Subscribe / Log in / New account

Toward generic atomic operations

Toward generic atomic operations

Posted Aug 2, 2012 5:23 UTC (Thu) by kev009 (guest, #43906)
Parent article: Toward generic atomic operations

Some of the tips in this article are pretty cavalier. Notably, until C11 is common enough to be required by a project, one _SHOULD_ use a library like libatomic_ops (from Boehm GC) for these operations and NOT proprietary compiler extensions.


to post comments

Toward generic atomic operations

Posted Aug 2, 2012 7:42 UTC (Thu) by jcm (subscriber, #18262) [Link]

Good points. The intention here is not to advocate for "proprietary extensions", but on some level I'm saying that if a project relies upon GCC, it's worth just considering using their existing atomics rather than re-implementing the wheel with inline assembly. An preferred alternative is to use an existing library, but that is not always possible. I just reviewed some of the Fedora ARM codebase for inline assembly and this kind of stuff showed up way more than I expected. It's something that needs fixing. I hope C11 is quickly adopted as means to do so.

Toward generic atomic operations

Posted Aug 2, 2012 14:37 UTC (Thu) by tvld (guest, #59052) [Link]

Also note that the atomics are just a part of the memory model. Using libatomic-ops, for example, does not guarantee that your compiler actually adheres to the memory model (e.g., does not introduce speculative stores that could be data races in a multi-threaded execution). There are different opinions about whether the C++11/C11 memory model should be the default even for non C++11/C11 compilations. IMO, this would be A Good Thing; other people are worried about potential performance disadvantages for single-threaded programs.


Copyright © 2025, Eklektix, Inc.
Comments and public postings are copyrighted by their creators.
Linux is a registered trademark of Linus Torvalds