• 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. Context">
8<link rel="up" href="../ff.html" title="Context switching with fibers">
9<link rel="prev" href="../ff.html" title="Context switching with fibers">
10<link rel="next" href="class__fiber_.html" title="Class fiber">
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="../ff.html"><img src="../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../ff.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="class__fiber_.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="context.ff.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<h5>
31<a name="context.ff.implementations__fcontext_t__ucontext_t_and_winfiber.h0"></a>
32        <span class="phrase"><a name="context.ff.implementations__fcontext_t__ucontext_t_and_winfiber.fcontext_t"></a></span><a class="link" href="implementations__fcontext_t__ucontext_t_and_winfiber.html#context.ff.implementations__fcontext_t__ucontext_t_and_winfiber.fcontext_t">fcontext_t</a>
33      </h5>
34<p>
35        The implementation uses <span class="emphasis"><em>fcontext_t</em></span> per default. fcontext_t
36        is based on assembler and not available for all platforms. It provides a
37        much better performance than <span class="emphasis"><em>ucontext_t</em></span> (the context
38        switch takes two magnitudes of order less CPU cycles; see section <a class="link" href="../performance.html#performance"><span class="emphasis"><em>performance</em></span></a>)
39        and <span class="emphasis"><em>WinFiber</em></span>.
40      </p>
41<div class="note"><table border="0" summary="Note">
42<tr>
43<td rowspan="2" align="center" valign="top" width="25"><img alt="[Note]" src="../../../../../../doc/src/images/note.png"></td>
44<th align="left">Note</th>
45</tr>
46<tr><td align="left" valign="top"><p>
47          Because the TIB (thread information block on Windows) is not fully described
48          in the MSDN, it might be possible that not all required TIB-parts are swapped.
49          Using WinFiber implementation migh be an alternative.
50        </p></td></tr>
51</table></div>
52<h5>
53<a name="context.ff.implementations__fcontext_t__ucontext_t_and_winfiber.h1"></a>
54        <span class="phrase"><a name="context.ff.implementations__fcontext_t__ucontext_t_and_winfiber.ucontext_t"></a></span><a class="link" href="implementations__fcontext_t__ucontext_t_and_winfiber.html#context.ff.implementations__fcontext_t__ucontext_t_and_winfiber.ucontext_t">ucontext_t</a>
55      </h5>
56<p>
57        As an alternative, <a href="https://en.wikipedia.org/wiki/Setcontext" target="_top"><span class="emphasis"><em>ucontext_t</em></span></a>
58        can be used by compiling with <code class="computeroutput"><span class="identifier">BOOST_USE_UCONTEXT</span></code>
59        and 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>.
60        <span class="emphasis"><em>ucontext_t</em></span> might be available on a broader range of
61        POSIX-platforms but has some <a class="link" href="../rationale/other_apis_.html#ucontext"><span class="emphasis"><em>disadvantages</em></span></a>
62        (for instance deprecated since POSIX.1-2003, not C99 conform).
63      </p>
64<div class="note"><table border="0" summary="Note">
65<tr>
66<td rowspan="2" align="center" valign="top" width="25"><img alt="[Note]" src="../../../../../../doc/src/images/note.png"></td>
67<th align="left">Note</th>
68</tr>
69<tr><td align="left" valign="top"><p>
70          <a class="link" href="../ff.html#ff"><span class="emphasis"><em>fiber</em></span></a> supports <a class="link" href="../stack/segmented.html#segmented"><span class="emphasis"><em>Segmented
71          stacks</em></span></a> only with <span class="emphasis"><em>ucontext_t</em></span> as its
72          implementation.
73        </p></td></tr>
74</table></div>
75<h5>
76<a name="context.ff.implementations__fcontext_t__ucontext_t_and_winfiber.h2"></a>
77        <span class="phrase"><a name="context.ff.implementations__fcontext_t__ucontext_t_and_winfiber.winfiber"></a></span><a class="link" href="implementations__fcontext_t__ucontext_t_and_winfiber.html#context.ff.implementations__fcontext_t__ucontext_t_and_winfiber.winfiber">WinFiber</a>
78      </h5>
79<p>
80        With <code class="computeroutput"><span class="identifier">BOOST_USE_WINFIB</span></code> and
81        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>
82        Win32-Fibers are used as implementation for <a class="link" href="../ff.html#ff"><span class="emphasis"><em>fiber</em></span></a>.
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 class="link" href="../ff.html#ff"><span class="emphasis"><em>fiber</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 © 2014 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="../ff.html"><img src="../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../ff.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="class__fiber_.html"><img src="../../../../../../doc/src/images/next.png" alt="Next"></a>
107</div>
108</body>
109</html>
110