Howard Hinnant | 56f0d5b | 2010-10-05 16:44:40 +0000 | [diff] [blame] | 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><atomic> 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> |
Tanya Lattner | d08dbfc | 2015-08-05 03:59:14 +0000 | [diff] [blame] | 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> |
Eric Fiselier | b7fd0be | 2017-02-17 08:37:03 +0000 | [diff] [blame^] | 27 | <a href="https://bugs.llvm.org/">Bug Reports</a> |
Howard Hinnant | 56f0d5b | 2010-10-05 16:44:40 +0000 | [diff] [blame] | 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><atomic> design</h1> |
| 36 | <!--*********************************************************************--> |
| 37 | |
| 38 | <p> |
Howard Hinnant | 086b718 | 2010-10-06 16:15:10 +0000 | [diff] [blame] | 39 | There are currently 3 designs under consideration. They differ in where most |
Howard Hinnant | 0dee9cd | 2013-02-15 15:37:50 +0000 | [diff] [blame] | 40 | of the implementation work is done. The functionality exposed to the customer |
Howard Hinnant | 086b718 | 2010-10-06 16:15:10 +0000 | [diff] [blame] | 41 | should be identical (and conforming) for all three designs. |
Howard Hinnant | 56f0d5b | 2010-10-05 16:44:40 +0000 | [diff] [blame] | 42 | </p> |
| 43 | |
Howard Hinnant | 086b718 | 2010-10-06 16:15:10 +0000 | [diff] [blame] | 44 | <ol type="A"> |
Howard Hinnant | 56f0d5b | 2010-10-05 16:44:40 +0000 | [diff] [blame] | 45 | <li> |
Howard Hinnant | 086b718 | 2010-10-06 16:15:10 +0000 | [diff] [blame] | 46 | <a href="atomic_design_a.html">Minimal work for the library</a> |
Howard Hinnant | 56f0d5b | 2010-10-05 16:44:40 +0000 | [diff] [blame] | 47 | </li> |
| 48 | <li> |
Howard Hinnant | 086b718 | 2010-10-06 16:15:10 +0000 | [diff] [blame] | 49 | <a href="atomic_design_b.html">Something in between</a> |
Howard Hinnant | 56f0d5b | 2010-10-05 16:44:40 +0000 | [diff] [blame] | 50 | </li> |
| 51 | <li> |
Howard Hinnant | 086b718 | 2010-10-06 16:15:10 +0000 | [diff] [blame] | 52 | <a href="atomic_design_c.html">Minimal work for the front end</a> |
Howard Hinnant | 56f0d5b | 2010-10-05 16:44:40 +0000 | [diff] [blame] | 53 | </li> |
Howard Hinnant | 086b718 | 2010-10-06 16:15:10 +0000 | [diff] [blame] | 54 | </ol> |
Howard Hinnant | 56f0d5b | 2010-10-05 16:44:40 +0000 | [diff] [blame] | 55 | |
Howard Hinnant | 08f2969 | 2010-10-08 17:36:50 +0000 | [diff] [blame] | 56 | <p> |
| 57 | With any design, the (back end) compiler writer should note: |
| 58 | </p> |
| 59 | |
| 60 | <blockquote> |
| 61 | <p> |
| 62 | The decision to implement lock-free operations on any given type (or not) is an |
| 63 | ABI-binding decision. One can not change from treating a type as not lock free, |
| 64 | to lock free (or vice-versa) without breaking your ABI. |
| 65 | </p> |
| 66 | |
| 67 | <p> |
| 68 | Example: |
| 69 | </p> |
| 70 | |
| 71 | <blockquote><pre> |
| 72 | TU1.cc |
| 73 | ----------- |
| 74 | extern atomic<long long> A; |
| 75 | int foo() { return A.compare_exchange_strong(w, x); } |
| 76 | |
| 77 | TU2.cc |
| 78 | ----------- |
| 79 | extern atomic<long long> A; |
| 80 | void bar() { return A.compare_exchange_strong(y, z); } |
| 81 | </pre></blockquote> |
| 82 | </blockquote> |
| 83 | |
| 84 | <p> |
| 85 | If only <em>one</em> of these calls to <tt>compare_exchange_strong</tt> is |
| 86 | implemented with mutex-locked code, then that mutex-locked code will not be |
| 87 | executed mutually exclusively of the one implemented in a lock-free manner. |
| 88 | </p> |
| 89 | |
Howard Hinnant | 56f0d5b | 2010-10-05 16:44:40 +0000 | [diff] [blame] | 90 | </div> |
| 91 | </body> |
| 92 | </html> |