blob: 87a2f6249141424ae1abf44dac06672a18740f35 [file] [log] [blame]
Howard Hinnant1de22662010-10-05 16:44:40 +00001<!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.cs.uiuc.edu/mailman/listinfo/cfe-dev">cfe-dev</a>
26 <a href="http://lists.cs.uiuc.edu/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>
Howard Hinnanta35a35f2010-10-06 16:15:10 +000039There are currently 3 designs under consideration. They differ in where most
40of the implmentation work is done. The functionality exposed to the customer
41should be identical (and conforming) for all three designs.
Howard Hinnant1de22662010-10-05 16:44:40 +000042</p>
43
Howard Hinnanta35a35f2010-10-06 16:15:10 +000044<ol type="A">
Howard Hinnant1de22662010-10-05 16:44:40 +000045<li>
Howard Hinnanta35a35f2010-10-06 16:15:10 +000046<a href="atomic_design_a.html">Minimal work for the library</a>
Howard Hinnant1de22662010-10-05 16:44:40 +000047</li>
48<li>
Howard Hinnanta35a35f2010-10-06 16:15:10 +000049<a href="atomic_design_b.html">Something in between</a>
Howard Hinnant1de22662010-10-05 16:44:40 +000050</li>
51<li>
Howard Hinnanta35a35f2010-10-06 16:15:10 +000052<a href="atomic_design_c.html">Minimal work for the front end</a>
Howard Hinnant1de22662010-10-05 16:44:40 +000053</li>
Howard Hinnanta35a35f2010-10-06 16:15:10 +000054</ol>
Howard Hinnant1de22662010-10-05 16:44:40 +000055
Howard Hinnant71dee182010-10-08 17:36:50 +000056<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
Howard Hinnant1de22662010-10-05 16:44:40 +000090</div>
91</body>
92</html>