1<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> 2<html> 3<head> 4<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> 5<title>Chapter 18. Boost.Interprocess</title> 6<link rel="stylesheet" href="../../doc/src/boostbook.css" type="text/css"> 7<meta name="generator" content="DocBook XSL Stylesheets V1.79.1"> 8<link rel="home" href="index.html" title="The Boost C++ Libraries BoostBook Documentation Subset"> 9<link rel="up" href="libraries.html" title="Part I. The Boost C++ Libraries (BoostBook Subset)"> 10<link rel="prev" href="heap/acknowledgements.html" title="Acknowledgements"> 11<link rel="next" href="interprocess/quick_guide.html" title="Quick Guide for the Impatient"> 12</head> 13<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"> 14<table cellpadding="2" width="100%"><tr> 15<td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../boost.png"></td> 16<td align="center"><a href="../../index.html">Home</a></td> 17<td align="center"><a href="../../libs/libraries.htm">Libraries</a></td> 18<td align="center"><a href="http://www.boost.org/users/people.html">People</a></td> 19<td align="center"><a href="http://www.boost.org/users/faq.html">FAQ</a></td> 20<td align="center"><a href="../../more/index.htm">More</a></td> 21</tr></table> 22<hr> 23<div class="spirit-nav"> 24<a accesskey="p" href="heap/acknowledgements.html"><img src="../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="libraries.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="interprocess/quick_guide.html"><img src="../../doc/src/images/next.png" alt="Next"></a> 25</div> 26<div class="chapter"> 27<div class="titlepage"><div> 28<div><h2 class="title"> 29<a name="interprocess"></a>Chapter 18. Boost.Interprocess</h2></div> 30<div><div class="author"><h3 class="author"> 31<span class="firstname">Ion</span> <span class="surname">Gaztanaga</span> 32</h3></div></div> 33<div><p class="copyright">Copyright © 2005-2015 Ion Gaztanaga</p></div> 34<div><div class="legalnotice"> 35<a name="interprocess.legal"></a><p> 36 Distributed under the Boost Software License, Version 1.0. (See accompanying 37 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>) 38 </p> 39</div></div> 40</div></div> 41<div class="toc"> 42<p><b>Table of Contents</b></p> 43<dl class="toc"> 44<dt><span class="section"><a href="interprocess.html#interprocess.intro">Introduction</a></span></dt> 45<dd><dl> 46<dt><span class="section"><a href="interprocess.html#interprocess.intro.introduction_building_interprocess">Building 47 Boost.Interprocess</a></span></dt> 48<dt><span class="section"><a href="interprocess.html#interprocess.intro.tested_compilers">Tested compilers</a></span></dt> 49</dl></dd> 50<dt><span class="section"><a href="interprocess/quick_guide.html">Quick Guide for the Impatient</a></span></dt> 51<dd><dl> 52<dt><span class="section"><a href="interprocess/quick_guide.html#interprocess.quick_guide.qg_memory_pool">Using shared 53 memory as a pool of unnamed memory blocks</a></span></dt> 54<dt><span class="section"><a href="interprocess/quick_guide.html#interprocess.quick_guide.qg_named_interprocess">Creating 55 named shared memory objects</a></span></dt> 56<dt><span class="section"><a href="interprocess/quick_guide.html#interprocess.quick_guide.qg_offset_ptr">Using an offset 57 smart pointer for shared memory</a></span></dt> 58<dt><span class="section"><a href="interprocess/quick_guide.html#interprocess.quick_guide.qg_interprocess_container">Creating 59 vectors in shared memory</a></span></dt> 60<dt><span class="section"><a href="interprocess/quick_guide.html#interprocess.quick_guide.qg_interprocess_map">Creating 61 maps in shared memory</a></span></dt> 62</dl></dd> 63<dt><span class="section"><a href="interprocess/some_basic_explanations.html">Some basic explanations</a></span></dt> 64<dd><dl> 65<dt><span class="section"><a href="interprocess/some_basic_explanations.html#interprocess.some_basic_explanations.processes_and_threads">Processes 66 And Threads</a></span></dt> 67<dt><span class="section"><a href="interprocess/some_basic_explanations.html#interprocess.some_basic_explanations.sharing_information">Sharing 68 information between processes</a></span></dt> 69<dt><span class="section"><a href="interprocess/some_basic_explanations.html#interprocess.some_basic_explanations.persistence">Persistence 70 Of Interprocess Mechanisms</a></span></dt> 71<dt><span class="section"><a href="interprocess/some_basic_explanations.html#interprocess.some_basic_explanations.names">Names Of 72 Interprocess Mechanisms</a></span></dt> 73<dt><span class="section"><a href="interprocess/some_basic_explanations.html#interprocess.some_basic_explanations.constructors_destructors_and_resource_lifetime">Constructors, 74 destructors and lifetime of Interprocess named resources</a></span></dt> 75<dt><span class="section"><a href="interprocess/some_basic_explanations.html#interprocess.some_basic_explanations.permissions">Permissions</a></span></dt> 76</dl></dd> 77<dt><span class="section"><a href="interprocess/sharedmemorybetweenprocesses.html">Sharing memory 78 between processes</a></span></dt> 79<dd><dl> 80<dt><span class="section"><a href="interprocess/sharedmemorybetweenprocesses.html#interprocess.sharedmemorybetweenprocesses.sharedmemory">Shared 81 memory</a></span></dt> 82<dt><span class="section"><a href="interprocess/sharedmemorybetweenprocesses.html#interprocess.sharedmemorybetweenprocesses.mapped_file">Memory 83 Mapped Files</a></span></dt> 84<dt><span class="section"><a href="interprocess/sharedmemorybetweenprocesses.html#interprocess.sharedmemorybetweenprocesses.mapped_region">More 85 About Mapped Regions</a></span></dt> 86<dt><span class="section"><a href="interprocess/sharedmemorybetweenprocesses.html#interprocess.sharedmemorybetweenprocesses.mapped_region_object_limitations">Limitations 87 When Constructing Objects In Mapped Regions</a></span></dt> 88</dl></dd> 89<dt><span class="section"><a href="interprocess/offset_ptr.html">Mapping Address Independent Pointer: 90 offset_ptr</a></span></dt> 91<dt><span class="section"><a href="interprocess/synchronization_mechanisms.html">Synchronization 92 mechanisms</a></span></dt> 93<dd><dl> 94<dt><span class="section"><a href="interprocess/synchronization_mechanisms.html#interprocess.synchronization_mechanisms.synchronization_mechanisms_overview">Synchronization 95 mechanisms overview</a></span></dt> 96<dt><span class="section"><a href="interprocess/synchronization_mechanisms.html#interprocess.synchronization_mechanisms.mutexes">Mutexes</a></span></dt> 97<dt><span class="section"><a href="interprocess/synchronization_mechanisms.html#interprocess.synchronization_mechanisms.conditions">Conditions</a></span></dt> 98<dt><span class="section"><a href="interprocess/synchronization_mechanisms.html#interprocess.synchronization_mechanisms.semaphores">Semaphores</a></span></dt> 99<dt><span class="section"><a href="interprocess/synchronization_mechanisms.html#interprocess.synchronization_mechanisms.sharable_upgradable_mutexes">Sharable 100 and Upgradable Mutexes</a></span></dt> 101<dt><span class="section"><a href="interprocess/synchronization_mechanisms.html#interprocess.synchronization_mechanisms.lock_conversions">Lock 102 Transfers Through Move Semantics</a></span></dt> 103<dt><span class="section"><a href="interprocess/synchronization_mechanisms.html#interprocess.synchronization_mechanisms.file_lock">File 104 Locks</a></span></dt> 105<dt><span class="section"><a href="interprocess/synchronization_mechanisms.html#interprocess.synchronization_mechanisms.message_queue">Message 106 Queue</a></span></dt> 107</dl></dd> 108<dt><span class="section"><a href="interprocess/managed_memory_segments.html">Managed Memory Segments</a></span></dt> 109<dd><dl> 110<dt><span class="section"><a href="interprocess/managed_memory_segments.html#interprocess.managed_memory_segments.making_ipc_easy">Making 111 Interprocess Data Communication Easy</a></span></dt> 112<dt><span class="section"><a href="interprocess/managed_memory_segments.html#interprocess.managed_memory_segments.managed_shared_memory">Managed 113 Shared Memory</a></span></dt> 114<dt><span class="section"><a href="interprocess/managed_memory_segments.html#interprocess.managed_memory_segments.managed_mapped_files">Managed 115 Mapped File</a></span></dt> 116<dt><span class="section"><a href="interprocess/managed_memory_segments.html#interprocess.managed_memory_segments.managed_memory_segment_features">Managed 117 Memory Segment Features</a></span></dt> 118<dt><span class="section"><a href="interprocess/managed_memory_segments.html#interprocess.managed_memory_segments.managed_memory_segment_advanced_features">Managed 119 Memory Segment Advanced Features</a></span></dt> 120<dt><span class="section"><a href="interprocess/managed_memory_segments.html#interprocess.managed_memory_segments.managed_heap_memory_external_buffer">Managed 121 Heap Memory And Managed External Buffer</a></span></dt> 122</dl></dd> 123<dt><span class="section"><a href="interprocess/allocators_containers.html">Allocators, containers 124 and memory allocation algorithms</a></span></dt> 125<dd><dl> 126<dt><span class="section"><a href="interprocess/allocators_containers.html#interprocess.allocators_containers.allocator_introduction">Introduction 127 to Interprocess allocators</a></span></dt> 128<dt><span class="section"><a href="interprocess/allocators_containers.html#interprocess.allocators_containers.stl_allocators_segregated_storage">Segregated 129 storage node allocators</a></span></dt> 130<dt><span class="section"><a href="interprocess/allocators_containers.html#interprocess.allocators_containers.stl_allocators_adaptive">Adaptive 131 pool node allocators</a></span></dt> 132<dt><span class="section"><a href="interprocess/allocators_containers.html#interprocess.allocators_containers.containers_explained">Interprocess 133 and containers in managed memory segments</a></span></dt> 134<dt><span class="section"><a href="interprocess/allocators_containers.html#interprocess.allocators_containers.additional_containers">Boost 135 containers compatible with Boost.Interprocess</a></span></dt> 136</dl></dd> 137<dt><span class="section"><a href="interprocess/memory_algorithms.html">Memory allocation algorithms</a></span></dt> 138<dd><dl> 139<dt><span class="section"><a href="interprocess/memory_algorithms.html#interprocess.memory_algorithms.simple_seq_fit">simple_seq_fit: 140 A simple shared memory management algorithm</a></span></dt> 141<dt><span class="section"><a href="interprocess/memory_algorithms.html#interprocess.memory_algorithms.rbtree_best_fit">rbtree_best_fit: 142 Best-fit logarithmic-time complexity allocation</a></span></dt> 143</dl></dd> 144<dt><span class="section"><a href="interprocess/streams.html">Direct iostream formatting: vectorstream 145 and bufferstream</a></span></dt> 146<dd><dl> 147<dt><span class="section"><a href="interprocess/streams.html#interprocess.streams.vectorstream">Formatting directly 148 in your character vector: vectorstream</a></span></dt> 149<dt><span class="section"><a href="interprocess/streams.html#interprocess.streams.bufferstream">Formatting directly 150 in your character buffer: bufferstream</a></span></dt> 151</dl></dd> 152<dt><span class="section"><a href="interprocess/interprocess_smart_ptr.html">Ownership smart pointers</a></span></dt> 153<dd><dl> 154<dt><span class="section"><a href="interprocess/interprocess_smart_ptr.html#interprocess.interprocess_smart_ptr.intrusive_ptr">Intrusive 155 pointer</a></span></dt> 156<dt><span class="section"><a href="interprocess/interprocess_smart_ptr.html#interprocess.interprocess_smart_ptr.scoped_ptr">Scoped 157 pointer</a></span></dt> 158<dt><span class="section"><a href="interprocess/interprocess_smart_ptr.html#interprocess.interprocess_smart_ptr.shared_ptr">Shared 159 pointer and weak pointer</a></span></dt> 160<dt><span class="section"><a href="interprocess/interprocess_smart_ptr.html#interprocess.interprocess_smart_ptr.unique_ptr">Unique 161 pointer</a></span></dt> 162</dl></dd> 163<dt><span class="section"><a href="interprocess/architecture.html">Architecture and internals</a></span></dt> 164<dd><dl> 165<dt><span class="section"><a href="interprocess/architecture.html#interprocess.architecture.basic_guidelines">Basic guidelines</a></span></dt> 166<dt><span class="section"><a href="interprocess/architecture.html#interprocess.architecture.architecture_algorithm_to_managed">From 167 the memory algorithm to the managed segment</a></span></dt> 168<dt><span class="section"><a href="interprocess/architecture.html#interprocess.architecture.allocators_containers">Allocators 169 and containers</a></span></dt> 170<dt><span class="section"><a href="interprocess/architecture.html#interprocess.architecture.performance">Performance of 171 Boost.Interprocess</a></span></dt> 172</dl></dd> 173<dt><span class="section"><a href="interprocess/customizing_interprocess.html">Customizing Boost.Interprocess</a></span></dt> 174<dd><dl> 175<dt><span class="section"><a href="interprocess/customizing_interprocess.html#interprocess.customizing_interprocess.custom_interprocess_alloc">Writing 176 a new shared memory allocation algorithm</a></span></dt> 177<dt><span class="section"><a href="interprocess/customizing_interprocess.html#interprocess.customizing_interprocess.custom_allocators">Building 178 custom STL compatible allocators for Boost.Interprocess</a></span></dt> 179<dt><span class="section"><a href="interprocess/customizing_interprocess.html#interprocess.customizing_interprocess.custom_indexes">Building 180 custom indexes</a></span></dt> 181</dl></dd> 182<dt><span class="section"><a href="interprocess/acknowledgements_notes.html">Acknowledgements, 183 notes and links</a></span></dt> 184<dd><dl> 185<dt><span class="section"><a href="interprocess/acknowledgements_notes.html#interprocess.acknowledgements_notes.notes_windows">Notes 186 for Windows users</a></span></dt> 187<dt><span class="section"><a href="interprocess/acknowledgements_notes.html#interprocess.acknowledgements_notes.notes_linux">Notes 188 for Linux users</a></span></dt> 189<dt><span class="section"><a href="interprocess/acknowledgements_notes.html#interprocess.acknowledgements_notes.notes_freebsd">Notes 190 for FreeBSD users</a></span></dt> 191<dt><span class="section"><a href="interprocess/acknowledgements_notes.html#interprocess.acknowledgements_notes.thanks_to">Thanks 192 to...</a></span></dt> 193<dt><span class="section"><a href="interprocess/acknowledgements_notes.html#interprocess.acknowledgements_notes.release_notes">Release 194 Notes</a></span></dt> 195<dt><span class="section"><a href="interprocess/acknowledgements_notes.html#interprocess.acknowledgements_notes.books_and_links">Books 196 and interesting links</a></span></dt> 197<dt><span class="section"><a href="interprocess/acknowledgements_notes.html#interprocess.acknowledgements_notes.future_improvements">Future 198 improvements...</a></span></dt> 199</dl></dd> 200<dt><span class="section"><a href="interprocess/indexes_reference.html">Indexes and Reference</a></span></dt> 201<dd><dl> 202<dt><span class="section"><a href="interprocess/indexes_reference.html#interprocess.indexes_reference.index">Indexes</a></span></dt> 203<dt><span class="section"><a href="interprocess/indexes_reference.html#boost_interprocess_header_reference">Boost.Interprocess Header Reference</a></span></dt> 204</dl></dd> 205</dl> 206</div> 207<div class="section"> 208<div class="titlepage"><div><div><h2 class="title" style="clear: both"> 209<a name="interprocess.intro"></a><a class="link" href="interprocess.html#interprocess.intro" title="Introduction">Introduction</a> 210</h2></div></div></div> 211<div class="toc"><dl class="toc"> 212<dt><span class="section"><a href="interprocess.html#interprocess.intro.introduction_building_interprocess">Building 213 Boost.Interprocess</a></span></dt> 214<dt><span class="section"><a href="interprocess.html#interprocess.intro.tested_compilers">Tested compilers</a></span></dt> 215</dl></div> 216<p> 217 <span class="bold"><strong>Boost.Interprocess</strong></span> simplifies the use of common 218 interprocess communication and synchronization mechanisms and offers a wide 219 range of them: 220 </p> 221<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "> 222<li class="listitem"> 223 Shared memory. 224 </li> 225<li class="listitem"> 226 Memory-mapped files. 227 </li> 228<li class="listitem"> 229 Semaphores, mutexes, condition variables and upgradable mutex types to 230 place them in shared memory and memory mapped files. 231 </li> 232<li class="listitem"> 233 Named versions of those synchronization objects, similar to UNIX/Windows 234 sem_open/CreateSemaphore API. 235 </li> 236<li class="listitem"> 237 File locking. 238 </li> 239<li class="listitem"> 240 Relative pointers. 241 </li> 242<li class="listitem"> 243 Message queues. 244 </li> 245</ul></div> 246<p> 247 <span class="bold"><strong>Boost.Interprocess</strong></span> also offers higher-level 248 interprocess mechanisms to allocate dynamically portions of a shared memory 249 or a memory mapped file (in general, to allocate portions of a fixed size memory 250 segment). Using these mechanisms, <span class="bold"><strong>Boost.Interprocess</strong></span> 251 offers useful tools to construct C++ objects, including STL-like containers, 252 in shared memory and memory mapped files: 253 </p> 254<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "> 255<li class="listitem"> 256 Dynamic creation of anonymous and named objects in a shared memory or memory 257 mapped file. 258 </li> 259<li class="listitem"> 260 STL-like containers compatible with shared memory/memory-mapped files. 261 </li> 262<li class="listitem"> 263 STL-like allocators ready for shared memory/memory-mapped files implementing 264 several memory allocation patterns (like pooling). 265 </li> 266</ul></div> 267<div class="section"> 268<div class="titlepage"><div><div><h3 class="title"> 269<a name="interprocess.intro.introduction_building_interprocess"></a><a class="link" href="interprocess.html#interprocess.intro.introduction_building_interprocess" title="Building Boost.Interprocess">Building 270 Boost.Interprocess</a> 271</h3></div></div></div> 272<p> 273 There is no need to compile <span class="bold"><strong>Boost.Interprocess</strong></span>, 274 since it's a header only library. Just include your Boost header directory 275 in your compiler include path. 276 </p> 277<p> 278 <span class="bold"><strong>Boost.Interprocess</strong></span> depends on <a href="http://www.boost.org/libs/date_time/" target="_top"><span class="bold"><strong>Boost.DateTime</strong></span></a>, which needs separate compilation. 279 However, the subset used by <span class="bold"><strong>Boost.Interprocess</strong></span> 280 does not need any separate compilation so the user can define <code class="computeroutput"><span class="identifier">BOOST_DATE_TIME_NO_LIB</span></code> to avoid Boost from 281 trying to automatically link the <span class="bold"><strong>Boost.DateTime</strong></span>. 282 </p> 283<p> 284 In POSIX systems, <span class="bold"><strong>Boost.Interprocess</strong></span> uses 285 pthread system calls to implement classes like mutexes, condition variables, 286 etc... In some operating systems, these POSIX calls are implemented in separate 287 libraries that are not automatically linked by the compiler. For example, 288 in some Linux systems POSIX pthread functions are implemented in <code class="computeroutput"><span class="identifier">librt</span><span class="special">.</span><span class="identifier">a</span></code> library, so you might need to add that 289 library when linking an executable or shared library that uses <span class="bold"><strong>Boost.Interprocess</strong></span>. If you obtain linking errors related 290 to those pthread functions, please revise your system's documentation to 291 know which library implements them. 292 </p> 293</div> 294<div class="section"> 295<div class="titlepage"><div><div><h3 class="title"> 296<a name="interprocess.intro.tested_compilers"></a><a class="link" href="interprocess.html#interprocess.intro.tested_compilers" title="Tested compilers">Tested compilers</a> 297</h3></div></div></div> 298<p> 299 <span class="bold"><strong>Boost.Interprocess</strong></span> has been tested in the 300 following compilers/platforms: 301 </p> 302<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "> 303<li class="listitem"> 304 Visual C++ >= 7.1. 305 </li> 306<li class="listitem"> 307 GCC >= 4.1. 308 </li> 309</ul></div> 310<div class="warning"><table border="0" summary="Warning"> 311<tr> 312<td rowspan="2" align="center" valign="top" width="25"><img alt="[Warning]" src="../../doc/src/images/warning.png"></td> 313<th align="left">Warning</th> 314</tr> 315<tr><td align="left" valign="top"><p> 316 GCC < 4.3 and MSVC < 9.0 are deprecated and will be removed in the 317 next version. 318 </p></td></tr> 319</table></div> 320</div> 321</div> 322</div> 323<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr> 324<td align="left"><p><small>Last revised: August 11, 2020 at 15:03:34 GMT</small></p></td> 325<td align="right"><div class="copyright-footer"></div></td> 326</tr></table> 327<hr> 328<div class="spirit-nav"> 329<a accesskey="p" href="heap/acknowledgements.html"><img src="../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="libraries.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="interprocess/quick_guide.html"><img src="../../doc/src/images/next.png" alt="Next"></a> 330</div> 331</body> 332</html> 333