1<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
2          "http://www.w3.org/TR/html4/strict.dtd">
3<!-- Material used from: HTML 4.01 specs: http://www.w3.org/TR/html401/ -->
4<html>
5<head>
6  <META http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
7  <title>&lt;atomic&gt; design</title>
8  <link type="text/css" rel="stylesheet" href="menu.css">
9  <link type="text/css" rel="stylesheet" href="content.css">
10</head>
11
12<body>
13<div id="menu">
14  <div>
15    <a href="http://llvm.org/">LLVM Home</a>
16  </div>
17
18  <div class="submenu">
19    <label>libc++ Info</label>
20    <a href="/index.html">About</a>
21  </div>
22
23  <div class="submenu">
24    <label>Quick Links</label>
25    <a href="http://lists.llvm.org/mailman/listinfo/cfe-dev">cfe-dev</a>
26    <a href="http://lists.llvm.org/mailman/listinfo/cfe-commits">cfe-commits</a>
27    <a href="http://llvm.org/bugs/">Bug Reports</a>
28    <a href="http://llvm.org/svn/llvm-project/libcxx/trunk/">Browse SVN</a>
29    <a href="http://llvm.org/viewvc/llvm-project/libcxx/trunk/">Browse ViewVC</a>
30  </div>
31</div>
32
33<div id="content">
34  <!--*********************************************************************-->
35  <h1>&lt;atomic&gt; design</h1>
36  <!--*********************************************************************-->
37
38<p>
39There are currently 3 designs under consideration.  They differ in where most
40of the implementation work is done.  The functionality exposed to the customer
41should be identical (and conforming) for all three designs.
42</p>
43
44<ol type="A">
45<li>
46<a href="atomic_design_a.html">Minimal work for the library</a>
47</li>
48<li>
49<a href="atomic_design_b.html">Something in between</a>
50</li>
51<li>
52<a href="atomic_design_c.html">Minimal work for the front end</a>
53</li>
54</ol>
55
56<p>
57With any design, the (back end) compiler writer should note:
58</p>
59
60<blockquote>
61<p>
62The decision to implement lock-free operations on any given type (or not) is an
63ABI-binding decision.  One can not change from treating a type as not lock free,
64to lock free (or vice-versa) without breaking your ABI.
65</p>
66
67<p>
68Example:
69</p>
70
71<blockquote><pre>
72TU1.cc
73-----------
74extern atomic&lt;long long&gt; A;
75int foo() { return A.compare_exchange_strong(w, x); }
76
77TU2.cc
78-----------
79extern atomic&lt;long long&gt; A;
80void bar() { return A.compare_exchange_strong(y, z); }
81</pre></blockquote>
82</blockquote>
83
84<p>
85If only <em>one</em> of these calls to <tt>compare_exchange_strong</tt> is
86implemented with mutex-locked code, then that mutex-locked code will not be
87executed mutually exclusively of the one implemented in a lock-free manner.
88</p>
89
90</div>
91</body>
92</html>
93