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