2
0
mirror of https://github.com/boostorg/fiber.git synced 2026-02-17 13:42:21 +00:00
Files
fiber/doc/html/fiber/rational.html
Oliver Kowalke 2fcf006f90 fix docu
2015-08-12 19:40:09 +02:00

145 lines
8.9 KiB
HTML

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
<title>Rational</title>
<link rel="stylesheet" href="../../../../../doc/src/boostbook.css" type="text/css">
<meta name="generator" content="DocBook XSL Stylesheets V1.75.2">
<link rel="home" href="../index.html" title="Chapter&#160;1.&#160;Fiber">
<link rel="up" href="../index.html" title="Chapter&#160;1.&#160;Fiber">
<link rel="prev" href="performance.html" title="Performance">
<link rel="next" href="custom.html" title="Customization">
</head>
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
<table cellpadding="2" width="100%"><tr>
<td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../../../../boost.png"></td>
<td align="center"><a href="../../../../../index.html">Home</a></td>
<td align="center"><a href="../../../../../libs/libraries.htm">Libraries</a></td>
<td align="center"><a href="http://www.boost.org/users/people.html">People</a></td>
<td align="center"><a href="http://www.boost.org/users/faq.html">FAQ</a></td>
<td align="center"><a href="../../../../../more/index.htm">More</a></td>
</tr></table>
<hr>
<div class="spirit-nav">
<a accesskey="p" href="performance.html"><img src="../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../index.html"><img src="../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../index.html"><img src="../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="custom.html"><img src="../../../../../doc/src/images/next.png" alt="Next"></a>
</div>
<div class="section">
<div class="titlepage"><div><div><h2 class="title" style="clear: both">
<a name="fiber.rational"></a><a class="link" href="rational.html" title="Rational">Rational</a>
</h2></div></div></div>
<h4>
<a name="fiber.rational.h0"></a>
<span><a name="fiber.rational.distinction_between_coroutines_and_fibers"></a></span><a class="link" href="rational.html#fiber.rational.distinction_between_coroutines_and_fibers">distinction
between coroutines and fibers</a>
</h4>
<p>
The fiber library extends the coroutine library by adding a scheduler and synchronization
mechanisms.
</p>
<pre class="programlisting"><span class="special">*</span> <span class="identifier">a</span> <span class="identifier">coroutine</span> <span class="identifier">yields</span>
<span class="special">*</span> <span class="identifier">a</span> <span class="identifier">fiber</span> <span class="identifier">blocks</span>
</pre>
<p>
When a coroutine yields, it passes control directly to its caller (or, in the
case of symmetric coroutines, a designated other coroutine). When a fiber blocks,
it implicitly passes control to the fiber scheduler. Coroutines have no scheduler
because they need no scheduler. <sup>[<a name="fiber.rational.f0" href="#ftn.fiber.rational.f0" class="footnote">2</a>]</sup>.
</p>
<h4>
<a name="fiber.rational.h1"></a>
<span><a name="fiber.rational.what_about_transactional_memory"></a></span><a class="link" href="rational.html#fiber.rational.what_about_transactional_memory">what
about transactional memory</a>
</h4>
<p>
GCC support transactional memory since version 4.7. Unfortunately testes showed
that transactional memory is slower (ca. 4x) than using spinlocks using atomics.
If transactional memory will be improved (supporting hybrid tm), spinlocks
will be replaced by __transaction_atomic{} statements surrounding the critical
sections.
</p>
<h4>
<a name="fiber.rational.h2"></a>
<span><a name="fiber.rational.synchronization_between_fibers_running_in_different_threads"></a></span><a class="link" href="rational.html#fiber.rational.synchronization_between_fibers_running_in_different_threads">synchronization
between fibers running in different threads</a>
</h4>
<p>
Synchronization classes from <a href="../../../../../libs/thread/index.html" target="_top">Boost.Thread</a>
do block the entire thread. In contrast to this the synchronization classes
from <span class="bold"><strong>Boost.Fiber</strong></span> do block only the fiber,
so that the thread is able to schedule and run other fibers in the meantime.
The synchronization classes from <span class="bold"><strong>Boost.Fiber</strong></span>
are designed to be thread-safe, e.g. it is possible to synchronize fibers running
in different schedulers (different threads) or running in the same scheduler
(same thread). (However, there is a build option to disable that support; see
<a class="link" href="overview.html#cross_thread_sync">this description</a>.)
</p>
<h4>
<a name="fiber.rational.h3"></a>
<span><a name="fiber.rational.support_for_boost_asio"></a></span><a class="link" href="rational.html#fiber.rational.support_for_boost_asio">support
for Boost.Asio</a>
</h4>
<p>
The support for Boost.Asio's <span class="emphasis"><em>async-result</em></span> is not part
of the official API (implementation provided in example section). <span class="emphasis"><em>async-result</em></span>
does not reflect that <span class="bold"><strong>Boost.Fiber</strong></span> itself uses
an internal scheduler (especially fibers not in touch with code using <a href="../../../../../libs/asio/index.html" target="_top">Boost.Asio</a>, for instance a sleeping
fiber will not be launched explicitly by <a href="../../../../../libs/asio/index.html" target="_top">Boost.Asio</a>).
The integration of <span class="bold"><strong>Boost.Fiber</strong></span> into <a href="../../../../../libs/asio/index.html" target="_top">Boost.Asio</a> requires some investigation
from both authors.
</p>
<h4>
<a name="fiber.rational.h4"></a>
<span><a name="fiber.rational.tested_compilers"></a></span><a class="link" href="rational.html#fiber.rational.tested_compilers">tested
compilers</a>
</h4>
<p>
The library was tested with GCC-5.1.1, Clang-3.6.0 and MSVC-14.0 in c++14-mode.
</p>
<h4>
<a name="fiber.rational.h5"></a>
<span><a name="fiber.rational.supported_architectures"></a></span><a class="link" href="rational.html#fiber.rational.supported_architectures">supported
architectures</a>
</h4>
<p>
<span class="bold"><strong>Boost.Fiber</strong></span> depends on <a href="../../../../../libs/context/index.html" target="_top">Boost.Context</a>
- the list of supported architectures can be found <a href="../../../../../libs/context/doc/html/context/architectures.html" target="_top">here</a>.
</p>
<h4>
<a name="fiber.rational.h6"></a>
<span><a name="fiber.rational.migrating_fibers_between_threads"></a></span><a class="link" href="rational.html#fiber.rational.migrating_fibers_between_threads">migrating
fibers between threads</a>
</h4>
<p>
The support for migrating fibers between threads was removed. Especially in
the case of NUMA-architectures it is not always advised to migrate data between
threads. Suppose fiber <span class="emphasis"><em>f</em></span> is running on logical CPU <span class="emphasis"><em>cpu0</em></span>
which belongs to NUMA node <span class="emphasis"><em>node0</em></span>. The data of <span class="emphasis"><em>f</em></span>
are allocated on the physical memory located at <span class="emphasis"><em>node0</em></span>.
Migrating the fiber from <span class="emphasis"><em>cpu0</em></span> to another logical CPU
<span class="emphasis"><em>cpuX</em></span> which is part of NUMA node <span class="emphasis"><em>nodeX</em></span>
will reduce the performance of the application because of increased latency
of memory access.
</p>
<div class="footnotes">
<br><hr width="100" align="left">
<div class="footnote"><p><sup>[<a name="ftn.fiber.rational.f0" href="#fiber.rational.f0" class="para">2</a>] </sup>
<a href="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2014/n4024.pdf" target="_top">'N4024:
Distinguishing coroutines and fibers'</a>
</p></div>
</div>
</div>
<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
<td align="left"></td>
<td align="right"><div class="copyright-footer">Copyright &#169; 2013 Oliver Kowalke<p>
Distributed under the Boost Software License, Version 1.0. (See accompanying
file LICENSE_1_0.txt or copy at <a href="http://www.boost.org/LICENSE_1_0.txt" target="_top">http://www.boost.org/LICENSE_1_0.txt</a>)
</p>
</div></td>
</tr></table>
<hr>
<div class="spirit-nav">
<a accesskey="p" href="performance.html"><img src="../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../index.html"><img src="../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../index.html"><img src="../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="custom.html"><img src="../../../../../doc/src/images/next.png" alt="Next"></a>
</div>
</body>
</html>