<html>
<head>
<meta content="text/html; charset=UTF-8" http-equiv="Content-Type">
</head>
<body>
On a second thought:<br>
<br>
Is it correct that atomic_set() without a writebarrier following it
is still atomic (no torn writes), however not guaranteed to be
visible to other threads?<br>
<br>
<div class="moz-cite-prefix">On 26/03/15 17:47, Malte Vesper wrote:<br>
</div>
<blockquote cite="mid:5514463A.2010109@postgrad.manchester.ac.uk"
type="cite">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
Hello,<br>
I have been reading up on atomics and struggle to grasp when
exactly I need explicit memory barriers.<br>
<br>
While the documentation (Documentat/atomic_ops.txt), talks about
operations needing explicit barriers both sides, I assume this is
only half true.<br>
If I for instance only want to use an atomic as a flag to show
that some operation is complete I reckon that a barrier before is
sufficient.<br>
<br>
Furthermore I found the following lines:<br>
<pre><span class="lno"><a moz-do-not-send="true" id="L288" href="http://users.sosdg.org/%7Eqiyong/lxr/source/Documentation/atomic_ops.txt#L288">288</a> </span><span class="code">If a caller requires memory barrier semantics around an atomic_t</span>
<span class="lno"><a moz-do-not-send="true" id="L289" href="http://users.sosdg.org/%7Eqiyong/lxr/source/Documentation/atomic_ops.txt#L289">289</a> </span><span class="code">operation which does not return a value, a set of interfaces are</span>
<span class="lno"><a moz-do-not-send="true" id="L290" href="http://users.sosdg.org/%7Eqiyong/lxr/source/Documentation/atomic_ops.txt#L290">290</a> </span><span class="code">defined which accomplish this:</span>
<span class="lno"><a moz-do-not-send="true" id="L291" href="http://users.sosdg.org/%7Eqiyong/lxr/source/Documentation/atomic_ops.txt#L291">291</a> </span><span class="code"></span>
<span class="lno"><a moz-do-not-send="true" id="L292" href="http://users.sosdg.org/%7Eqiyong/lxr/source/Documentation/atomic_ops.txt#L292">292</a> </span><span class="code">        void smp_mb__before_atomic(void);</span>
<span class="lno"><a moz-do-not-send="true" id="L293" href="http://users.sosdg.org/%7Eqiyong/lxr/source/Documentation/atomic_ops.txt#L293">293</a> </span><span class="code">        void smp_mb__after_atomic(void);</span></pre>
note how it refers to "operation which does not return a value",
why can't I use these for atomic operations that do return a
value?<br>
What should I use instead, normal barriers like mb?<br>
<br>
Please enlighten me<br>
Malte<br>
</blockquote>
<br>
</body>
</html>