• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1<html>
2<head>
3<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
4<title>Implementations: fcontext_t, ucontext_t and WinFiber</title>
5<link rel="stylesheet" href="../../../../../../doc/src/boostbook.css" type="text/css">
6<meta name="generator" content="DocBook XSL Stylesheets V1.79.1">
7<link rel="home" href="../../index.html" title="Chapter 1. Fiber">
8<link rel="up" href="../overview.html" title="Overview">
9<link rel="prev" href="../overview.html" title="Overview">
10<link rel="next" href="../fiber_mgmt.html" title="Fiber management">
11</head>
12<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
13<table cellpadding="2" width="100%"><tr>
14<td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../../../../../boost.png"></td>
15<td align="center"><a href="../../../../../../index.html">Home</a></td>
16<td align="center"><a href="../../../../../../libs/libraries.htm">Libraries</a></td>
17<td align="center"><a href="http://www.boost.org/users/people.html">People</a></td>
18<td align="center"><a href="http://www.boost.org/users/faq.html">FAQ</a></td>
19<td align="center"><a href="../../../../../../more/index.htm">More</a></td>
20</tr></table>
21<hr>
22<div class="spirit-nav">
23<a accesskey="p" href="../overview.html"><img src="../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../overview.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="../fiber_mgmt.html"><img src="../../../../../../doc/src/images/next.png" alt="Next"></a>
24</div>
25<div class="section">
26<div class="titlepage"><div><div><h3 class="title">
27<a name="fiber.overview.implementations__fcontext_t__ucontext_t_and_winfiber"></a><a name="implementation"></a><a class="link" href="implementations__fcontext_t__ucontext_t_and_winfiber.html" title="Implementations: fcontext_t, ucontext_t and WinFiber">Implementations:
28      fcontext_t, ucontext_t and WinFiber</a>
29</h3></div></div></div>
30<p>
31        <span class="bold"><strong>Boost.Fiber</strong></span> uses <a href="http://www.boost.org/doc/libs/release/libs/context/doc/html/context/cc.html" target="_top"><span class="emphasis"><em>call/cc</em></span></a>
32        from <a href="http://www.boost.org/doc/libs/release/libs/context/index.html" target="_top">Boost.Context</a>
33        as building-block.
34      </p>
35<h5>
36<a name="fiber.overview.implementations__fcontext_t__ucontext_t_and_winfiber.h0"></a>
37        <span class="phrase"><a name="fiber.overview.implementations__fcontext_t__ucontext_t_and_winfiber.fcontext_t"></a></span><a class="link" href="implementations__fcontext_t__ucontext_t_and_winfiber.html#fiber.overview.implementations__fcontext_t__ucontext_t_and_winfiber.fcontext_t">fcontext_t</a>
38      </h5>
39<p>
40        The implementation uses <code class="computeroutput"><span class="identifier">fcontext_t</span></code>
41        per default. fcontext_t is based on assembler and not available for all platforms.
42        It provides a much better performance than <code class="computeroutput"><span class="identifier">ucontext_t</span></code>
43        (the context switch takes two magnitudes of order less CPU cycles; see section
44        <a href="http://www.boost.org/doc/libs/release/libs/context/doc/html/context/performance.html" target="_top"><span class="emphasis"><em>performance</em></span></a>)
45        and <code class="computeroutput"><span class="identifier">WinFiber</span></code>.
46      </p>
47<h5>
48<a name="fiber.overview.implementations__fcontext_t__ucontext_t_and_winfiber.h1"></a>
49        <span class="phrase"><a name="fiber.overview.implementations__fcontext_t__ucontext_t_and_winfiber.ucontext_t"></a></span><a class="link" href="implementations__fcontext_t__ucontext_t_and_winfiber.html#fiber.overview.implementations__fcontext_t__ucontext_t_and_winfiber.ucontext_t">ucontext_t</a>
50      </h5>
51<p>
52        As an alternative, <a href="https://en.wikipedia.org/wiki/Setcontext" target="_top"><code class="computeroutput"><span class="identifier">ucontext_t</span></code></a> can be used by compiling
53        with <code class="computeroutput"><span class="identifier">BOOST_USE_UCONTEXT</span></code> and
54        b2 property <code class="computeroutput"><span class="identifier">context</span><span class="special">-</span><span class="identifier">impl</span><span class="special">=</span><span class="identifier">ucontext</span></code>.
55        <code class="computeroutput"><span class="identifier">ucontext_t</span></code> might be available
56        on a broader range of POSIX-platforms but has some <a href="http://www.boost.org/doc/libs/release/libs/context/doc/html/context/rational.html#ucontext" target="_top"><span class="emphasis"><em>disadvantages</em></span></a>
57        (for instance deprecated since POSIX.1-2003, not C99 conform).
58      </p>
59<div class="note"><table border="0" summary="Note">
60<tr>
61<td rowspan="2" align="center" valign="top" width="25"><img alt="[Note]" src="../../../../../../doc/src/images/note.png"></td>
62<th align="left">Note</th>
63</tr>
64<tr><td align="left" valign="top"><p>
65          <a href="http://www.boost.org/doc/libs/release/libs/context/doc/html/context/cc.html" target="_top"><span class="emphasis"><em>call/cc</em></span></a>
66          supports <a class="link" href="../stack.html#segmented"><span class="emphasis"><em>Segmented stacks</em></span></a>
67          only with <code class="computeroutput"><span class="identifier">ucontext_t</span></code> as
68          its implementation.
69        </p></td></tr>
70</table></div>
71<h5>
72<a name="fiber.overview.implementations__fcontext_t__ucontext_t_and_winfiber.h2"></a>
73        <span class="phrase"><a name="fiber.overview.implementations__fcontext_t__ucontext_t_and_winfiber.winfiber"></a></span><a class="link" href="implementations__fcontext_t__ucontext_t_and_winfiber.html#fiber.overview.implementations__fcontext_t__ucontext_t_and_winfiber.winfiber">WinFiber</a>
74      </h5>
75<p>
76        With <code class="computeroutput"><span class="identifier">BOOST_USE_WINFIB</span></code> and
77        b2 property <code class="computeroutput"><span class="identifier">context</span><span class="special">-</span><span class="identifier">impl</span><span class="special">=</span><span class="identifier">winfib</span></code>
78        Win32-Fibers are used as implementation for <a href="http://www.boost.org/doc/libs/release/libs/context/doc/html/context/cc.html" target="_top"><span class="emphasis"><em>call/cc</em></span></a>.
79      </p>
80<p>
81        Because the TIB (thread information block) is not fully described in the
82        MSDN, it might be possible that not all required TIB-parts are swapped.
83      </p>
84<div class="note"><table border="0" summary="Note">
85<tr>
86<td rowspan="2" align="center" valign="top" width="25"><img alt="[Note]" src="../../../../../../doc/src/images/note.png"></td>
87<th align="left">Note</th>
88</tr>
89<tr><td align="left" valign="top"><p>
90          The first call of <a href="http://www.boost.org/doc/libs/release/libs/context/doc/html/context/cc.html" target="_top"><span class="emphasis"><em>call/cc</em></span></a>
91          converts the thread into a Windows fiber by invoking <code class="computeroutput"><span class="identifier">ConvertThreadToFiber</span><span class="special">()</span></code>. If desired, <code class="computeroutput"><span class="identifier">ConvertFiberToThread</span><span class="special">()</span></code> has to be called by the user explicitly
92          in order to release resources allocated by <code class="computeroutput"><span class="identifier">ConvertThreadToFiber</span><span class="special">()</span></code> (e.g. after using boost.context).
93        </p></td></tr>
94</table></div>
95</div>
96<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
97<td align="left"></td>
98<td align="right"><div class="copyright-footer">Copyright © 2013 Oliver Kowalke<p>
99        Distributed under the Boost Software License, Version 1.0. (See accompanying
100        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>)
101      </p>
102</div></td>
103</tr></table>
104<hr>
105<div class="spirit-nav">
106<a accesskey="p" href="../overview.html"><img src="../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../overview.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="../fiber_mgmt.html"><img src="../../../../../../doc/src/images/next.png" alt="Next"></a>
107</div>
108</body>
109</html>
110