<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On Tue, Mar 1, 2016 at 12:09 PM, Sebastian Gesemann <span dir="ltr"><<a href="mailto:s.gesemann@gmail.com" target="_blank">s.gesemann@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div class=""><div class="h5"><br>
It depends on what meanings you attach to the words "atomics" and<br>
"atomicity". I was trying to use the term "atomic" in a way consistent<br>
with the C11/C++11 memory model. In this context, atomicity is not<br>
only about having logically multiple operations done as a single one<br>
(fetch-and-add, compare-and-swap, etc) but it also involves memory<br>
ordering hints (defaulting to sequential constistency but weaker<br>
models are possible). So, it seems to me that you were not familiar<br>
with this. I said I have little experience with lock-free programming<br>
but that does not mean I'm completely unaware of the theoretical<br>
aspects.<br></div></div></blockquote><div><br><div>the evil that lock-free data structures seek to avoid is mutual 
exclusion that involves stopping thread execution. they do not require 
that things are atomic in either the weak or strong sense, but they do 
require that the data structures remain consistent and accurate from the
 POV of the threads that use them. <br><br></div><div>the JACK implementation relies on two things to work:<br><br></div><div>   * pointer and integer operations are (weakly) atomic on all platforms that JACK runs on<br></div><div>   * code reordering will either not happen or will be prevented by the compiler<br><br></div><div>the first assumption is a strong one, and the second one is at best weak, and at worst actually incorrect.<br><br></div><div>the implementation inside Ardour uses glib's atomic wrappers to make the second assumption strong. <br><br><a href="https://github.com/Ardour/ardour/blob/master/libs/pbd/pbd/ringbuffer.h">https://github.com/Ardour/ardour/blob/master/libs/pbd/pbd/ringbuffer.h</a><br><br></div><div>(there is also a non-power-of-two size version one level up).<br></div><div><br></div><div><br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><span>
</span>Well, for me, that's part of the fun -- figuring out how it's supposed<br>
to be written without invoking U.B.<br></blockquote><div><br></div>"Never let what you are really seeking to accomplish interfere with deepening your knowledge of computer science".<br> </div><br></div></div></div>