OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-stable/] [gcc-4.5.1/] [libstdc++-v3/] [doc/] [html/] [manual/] [ext_concurrency.html] - Diff between revs 816 and 826

Go to most recent revision | Only display areas with differences | Details | Blame | View Log

Rev 816 Rev 826
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /><title>Chapter 41. Concurrency</title><meta name="generator" content="DocBook XSL Stylesheets V1.75.2" /><meta name="keywords" content="&#10;      ISO C++&#10;    , &#10;      library&#10;    " /><meta name="keywords" content="&#10;      ISO C++&#10;    , &#10;      library&#10;    " /><link rel="home" href="../spine.html" title="The GNU C++ Library Documentation" /><link rel="up" href="extensions.html" title="Part XII.  Extensions" /><link rel="prev" href="ext_demangling.html" title="Chapter 40. Demangling" /><link rel="next" href="bk01pt12ch41s02.html" title="Implementation" /></head><body><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="3" align="center">Chapter 41. Concurrency</th></tr><tr><td width="20%" align="left"><a accesskey="p" href="ext_demangling.html">Prev</a> </td><th width="60%" align="center">Part XII. 
<html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /><title>Chapter 41. Concurrency</title><meta name="generator" content="DocBook XSL Stylesheets V1.75.2" /><meta name="keywords" content="&#10;      ISO C++&#10;    , &#10;      library&#10;    " /><meta name="keywords" content="&#10;      ISO C++&#10;    , &#10;      library&#10;    " /><link rel="home" href="../spine.html" title="The GNU C++ Library Documentation" /><link rel="up" href="extensions.html" title="Part XII.  Extensions" /><link rel="prev" href="ext_demangling.html" title="Chapter 40. Demangling" /><link rel="next" href="bk01pt12ch41s02.html" title="Implementation" /></head><body><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="3" align="center">Chapter 41. Concurrency</th></tr><tr><td width="20%" align="left"><a accesskey="p" href="ext_demangling.html">Prev</a> </td><th width="60%" align="center">Part XII. 
  Extensions
  Extensions
 
 
</th><td width="20%" align="right"> <a accesskey="n" href="bk01pt12ch41s02.html">Next</a></td></tr></table><hr /></div><div class="chapter" title="Chapter 41. Concurrency"><div class="titlepage"><div><div><h2 class="title"><a id="manual.ext.concurrency"></a>Chapter 41. Concurrency</h2></div></div></div><div class="toc"><p><b>Table of Contents</b></p><dl><dt><span class="sect1"><a href="ext_concurrency.html#manual.ext.concurrency.design">Design</a></span></dt><dd><dl><dt><span class="sect2"><a href="ext_concurrency.html#manual.ext.concurrency.design.threads">Interface to Locks and Mutexes</a></span></dt><dt><span class="sect2"><a href="ext_concurrency.html#manual.ext.concurrency.design.atomics">Interface to Atomic Functions</a></span></dt></dl></dd><dt><span class="sect1"><a href="bk01pt12ch41s02.html">Implementation</a></span></dt><dd><dl><dt><span class="sect2"><a href="bk01pt12ch41s02.html#manual.ext.concurrency.impl.atomic_fallbacks">Using Builtin Atomic Functions</a></span></dt><dt><span class="sect2"><a href="bk01pt12ch41s02.html#manual.ext.concurrency.impl.thread">Thread Abstraction</a></span></dt></dl></dd><dt><span class="sect1"><a href="bk01pt12ch41s03.html">Use</a></span></dt></dl></div><div class="sect1" title="Design"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a id="manual.ext.concurrency.design"></a>Design</h2></div></div></div><div class="sect2" title="Interface to Locks and Mutexes"><div class="titlepage"><div><div><h3 class="title"><a id="manual.ext.concurrency.design.threads"></a>Interface to Locks and Mutexes</h3></div></div></div><p>The file &lt;ext/concurrence.h&gt; contains all the higher-level
</th><td width="20%" align="right"> <a accesskey="n" href="bk01pt12ch41s02.html">Next</a></td></tr></table><hr /></div><div class="chapter" title="Chapter 41. Concurrency"><div class="titlepage"><div><div><h2 class="title"><a id="manual.ext.concurrency"></a>Chapter 41. Concurrency</h2></div></div></div><div class="toc"><p><b>Table of Contents</b></p><dl><dt><span class="sect1"><a href="ext_concurrency.html#manual.ext.concurrency.design">Design</a></span></dt><dd><dl><dt><span class="sect2"><a href="ext_concurrency.html#manual.ext.concurrency.design.threads">Interface to Locks and Mutexes</a></span></dt><dt><span class="sect2"><a href="ext_concurrency.html#manual.ext.concurrency.design.atomics">Interface to Atomic Functions</a></span></dt></dl></dd><dt><span class="sect1"><a href="bk01pt12ch41s02.html">Implementation</a></span></dt><dd><dl><dt><span class="sect2"><a href="bk01pt12ch41s02.html#manual.ext.concurrency.impl.atomic_fallbacks">Using Builtin Atomic Functions</a></span></dt><dt><span class="sect2"><a href="bk01pt12ch41s02.html#manual.ext.concurrency.impl.thread">Thread Abstraction</a></span></dt></dl></dd><dt><span class="sect1"><a href="bk01pt12ch41s03.html">Use</a></span></dt></dl></div><div class="sect1" title="Design"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a id="manual.ext.concurrency.design"></a>Design</h2></div></div></div><div class="sect2" title="Interface to Locks and Mutexes"><div class="titlepage"><div><div><h3 class="title"><a id="manual.ext.concurrency.design.threads"></a>Interface to Locks and Mutexes</h3></div></div></div><p>The file &lt;ext/concurrence.h&gt; contains all the higher-level
constructs for playing with threads. In contrast to the atomics layer,
constructs for playing with threads. In contrast to the atomics layer,
the concurrence layer consists largely of types. All types are defined within <code class="code">namespace __gnu_cxx</code>.
the concurrence layer consists largely of types. All types are defined within <code class="code">namespace __gnu_cxx</code>.
</p><p>
</p><p>
These types can be used in a portable manner, regardless of the
These types can be used in a portable manner, regardless of the
specific environment. They are carefully designed to provide optimum
specific environment. They are carefully designed to provide optimum
efficiency and speed, abstracting out underlying thread calls and
efficiency and speed, abstracting out underlying thread calls and
accesses when compiling for single-threaded situations (even on hosts
accesses when compiling for single-threaded situations (even on hosts
that support multiple threads.)
that support multiple threads.)
</p><p>The enumerated type <code class="code">_Lock_policy</code> details the set of
</p><p>The enumerated type <code class="code">_Lock_policy</code> details the set of
available locking
available locking
policies: <code class="code">_S_single</code>, <code class="code">_S_mutex</code>,
policies: <code class="code">_S_single</code>, <code class="code">_S_mutex</code>,
and <code class="code">_S_atomic</code>.
and <code class="code">_S_atomic</code>.
</p><div class="itemizedlist"><ul class="itemizedlist" type="disc"><li class="listitem"><p><code class="code">_S_single</code></p><p>Indicates single-threaded code that does not need locking.
</p><div class="itemizedlist"><ul class="itemizedlist" type="disc"><li class="listitem"><p><code class="code">_S_single</code></p><p>Indicates single-threaded code that does not need locking.
</p></li><li class="listitem"><p><code class="code">_S_mutex</code></p><p>Indicates multi-threaded code using thread-layer abstractions.
</p></li><li class="listitem"><p><code class="code">_S_mutex</code></p><p>Indicates multi-threaded code using thread-layer abstractions.
</p></li><li class="listitem"><p><code class="code">_S_atomic</code></p><p>Indicates multi-threaded code using atomic operations.
</p></li><li class="listitem"><p><code class="code">_S_atomic</code></p><p>Indicates multi-threaded code using atomic operations.
</p></li></ul></div><p>The compile-time constant <code class="code">__default_lock_policy</code> is set
</p></li></ul></div><p>The compile-time constant <code class="code">__default_lock_policy</code> is set
to one of the three values above, depending on characteristics of the
to one of the three values above, depending on characteristics of the
host environment and the current compilation flags.
host environment and the current compilation flags.
</p><p>Two more datatypes make up the rest of the
</p><p>Two more datatypes make up the rest of the
interface: <code class="code">__mutex</code>, and <code class="code">__scoped_lock</code>.
interface: <code class="code">__mutex</code>, and <code class="code">__scoped_lock</code>.
</p><p>
</p><p>
</p><p>The scoped lock idiom is well-discussed within the C++
</p><p>The scoped lock idiom is well-discussed within the C++
community. This version takes a <code class="code">__mutex</code> reference, and
community. This version takes a <code class="code">__mutex</code> reference, and
locks it during construction of <code class="code">__scoped_locke</code> and
locks it during construction of <code class="code">__scoped_locke</code> and
unlocks it during destruction. This is an efficient way of locking
unlocks it during destruction. This is an efficient way of locking
critical sections, while retaining exception-safety.
critical sections, while retaining exception-safety.
</p></div><div class="sect2" title="Interface to Atomic Functions"><div class="titlepage"><div><div><h3 class="title"><a id="manual.ext.concurrency.design.atomics"></a>Interface to Atomic Functions</h3></div></div></div><p>
</p></div><div class="sect2" title="Interface to Atomic Functions"><div class="titlepage"><div><div><h3 class="title"><a id="manual.ext.concurrency.design.atomics"></a>Interface to Atomic Functions</h3></div></div></div><p>
Two functions and one type form the base of atomic support.
Two functions and one type form the base of atomic support.
</p><p>The type <code class="code">_Atomic_word</code> is a signed integral type
</p><p>The type <code class="code">_Atomic_word</code> is a signed integral type
supporting atomic operations.
supporting atomic operations.
</p><p>
</p><p>
The two functions functions are:
The two functions functions are:
</p><pre class="programlisting">
</p><pre class="programlisting">
_Atomic_word
_Atomic_word
__exchange_and_add_dispatch(volatile _Atomic_word*, int);
__exchange_and_add_dispatch(volatile _Atomic_word*, int);
 
 
void
void
__atomic_add_dispatch(volatile _Atomic_word*, int);
__atomic_add_dispatch(volatile _Atomic_word*, int);
</pre><p>Both of these functions are declared in the header file
</pre><p>Both of these functions are declared in the header file
&lt;ext/atomicity.h&gt;, and are in <code class="code">namespace __gnu_cxx</code>.
&lt;ext/atomicity.h&gt;, and are in <code class="code">namespace __gnu_cxx</code>.
</p><div class="itemizedlist"><ul class="itemizedlist" type="disc"><li class="listitem"><p>
</p><div class="itemizedlist"><ul class="itemizedlist" type="disc"><li class="listitem"><p>
<code class="code">
<code class="code">
__exchange_and_add_dispatch
__exchange_and_add_dispatch
</code>
</code>
</p><p>Adds the second argument's value to the first argument. Returns the old value.
</p><p>Adds the second argument's value to the first argument. Returns the old value.
</p></li><li class="listitem"><p>
</p></li><li class="listitem"><p>
<code class="code">
<code class="code">
__atomic_add_dispatch
__atomic_add_dispatch
</code>
</code>
</p><p>Adds the second argument's value to the first argument. Has no return value.
</p><p>Adds the second argument's value to the first argument. Has no return value.
</p></li></ul></div><p>
</p></li></ul></div><p>
These functions forward to one of several specialized helper
These functions forward to one of several specialized helper
functions, depending on the circumstances. For instance,
functions, depending on the circumstances. For instance,
</p><p>
</p><p>
<code class="code">
<code class="code">
__exchange_and_add_dispatch
__exchange_and_add_dispatch
</code>
</code>
</p><p>
</p><p>
Calls through to either of:
Calls through to either of:
</p><div class="itemizedlist"><ul class="itemizedlist" type="disc"><li class="listitem"><p><code class="code">__exchange_and_add</code>
</p><div class="itemizedlist"><ul class="itemizedlist" type="disc"><li class="listitem"><p><code class="code">__exchange_and_add</code>
</p><p>Multi-thread version. Inlined if compiler-generated builtin atomics
</p><p>Multi-thread version. Inlined if compiler-generated builtin atomics
can be used, otherwise resolved at link time to a non-builtin code
can be used, otherwise resolved at link time to a non-builtin code
sequence.
sequence.
</p></li><li class="listitem"><p><code class="code">__exchange_and_add_single</code>
</p></li><li class="listitem"><p><code class="code">__exchange_and_add_single</code>
</p><p>Single threaded version. Inlined.</p></li></ul></div><p>However, only <code class="code">__exchange_and_add_dispatch</code>
</p><p>Single threaded version. Inlined.</p></li></ul></div><p>However, only <code class="code">__exchange_and_add_dispatch</code>
and <code class="code">__atomic_add_dispatch</code> should be used. These functions
and <code class="code">__atomic_add_dispatch</code> should be used. These functions
can be used in a portable manner, regardless of the specific
can be used in a portable manner, regardless of the specific
environment. They are carefully designed to provide optimum efficiency
environment. They are carefully designed to provide optimum efficiency
and speed, abstracting out atomic accesses when they are not required
and speed, abstracting out atomic accesses when they are not required
(even on hosts that support compiler intrinsics for atomic
(even on hosts that support compiler intrinsics for atomic
operations.)
operations.)
</p><p>
</p><p>
In addition, there are two macros
In addition, there are two macros
</p><p>
</p><p>
<code class="code">
<code class="code">
_GLIBCXX_READ_MEM_BARRIER
_GLIBCXX_READ_MEM_BARRIER
</code>
</code>
</p><p>
</p><p>
<code class="code">
<code class="code">
_GLIBCXX_WRITE_MEM_BARRIER
_GLIBCXX_WRITE_MEM_BARRIER
</code>
</code>
</p><p>
</p><p>
Which expand to the appropriate write and read barrier required by the
Which expand to the appropriate write and read barrier required by the
host hardware and operating system.
host hardware and operating system.
</p></div></div></div><div class="navfooter"><hr /><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="ext_demangling.html">Prev</a> </td><td width="20%" align="center"><a accesskey="u" href="extensions.html">Up</a></td><td width="40%" align="right"> <a accesskey="n" href="bk01pt12ch41s02.html">Next</a></td></tr><tr><td width="40%" align="left" valign="top">Chapter 40. Demangling </td><td width="20%" align="center"><a accesskey="h" href="../spine.html">Home</a></td><td width="40%" align="right" valign="top"> Implementation</td></tr></table></div></body></html>
</p></div></div></div><div class="navfooter"><hr /><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="ext_demangling.html">Prev</a> </td><td width="20%" align="center"><a accesskey="u" href="extensions.html">Up</a></td><td width="40%" align="right"> <a accesskey="n" href="bk01pt12ch41s02.html">Next</a></td></tr><tr><td width="40%" align="left" valign="top">Chapter 40. Demangling </td><td width="20%" align="center"><a accesskey="h" href="../spine.html">Home</a></td><td width="40%" align="right" valign="top"> Implementation</td></tr></table></div></body></html>
 
 

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.