Boost C++ Libraries: Ticket #8094: hierarchical_mutex for lock hierarchies (to avoid deadlocks) https://svn.boost.org/trac10/ticket/8094 <p> It would be great if boost::thread could be extended with a "hierarchical" mutex to facilitate lock hierarchies. Lock hierarchies is a construct that associates mutexes with software layer numbers, and enforces the application to only lock "downwards" in the software hierarchy <a class="changeset" href="https://svn.boost.org/trac10/changeset/1" title="Import core sources for SVNmanger 0.38 ">[1]</a>. This effectively translates potential deadlocks into deterministic run-time failures that be detected during testing. </p> <p> An example draft implementation is attached. The attachment also includes a BOOST_THREAD_LOCAL work-around for missing "thread_local" support that should probably be moved to more neutral ground. </p> <p> <a class="changeset" href="https://svn.boost.org/trac10/changeset/1" title="Import core sources for SVNmanger 0.38 ">[1]</a> <a class="ext-link" href="http://www.drdobbs.com/parallel/use-lock-hierarchies-to-avoid-deadlock/204801163"><span class="icon">​</span>http://www.drdobbs.com/parallel/use-lock-hierarchies-to-avoid-deadlock/204801163</a> </p> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/8094 Trac 1.4.3 Fredrik Orderud <forderud@…> Sun, 17 Feb 2013 21:25:38 GMT attachment set https://svn.boost.org/trac10/ticket/8094 https://svn.boost.org/trac10/ticket/8094 <ul> <li><strong>attachment</strong> → <span class="trac-field-new">hierarchical_mutex.hpp</span> </li> </ul> Ticket viboes Sun, 17 Feb 2013 22:04:42 GMT owner, status, version changed https://svn.boost.org/trac10/ticket/8094#comment:1 https://svn.boost.org/trac10/ticket/8094#comment:1 <ul> <li><strong>owner</strong> changed from <span class="trac-author">Anthony Williams</span> to <span class="trac-author">viboes</span> </li> <li><strong>status</strong> <span class="trac-field-old">new</span> → <span class="trac-field-new">assigned</span> </li> <li><strong>version</strong> <span class="trac-field-old">Boost 1.52.0</span> → <span class="trac-field-new">Boost 1.53.0</span> </li> </ul> <p> I agree, and I had already on my to do list. However, much more work is needed to move it to Boost: </p> <ul><li>make the BOOST_THREAD_LOCAL part portable to compilers that doesn't have the needed feature. </li><li>add timed lock functions </li><li>provide tests </li><li>write the doc: a motivating section, a brief tutorial, an example and the reference </li></ul><p> if you can help on any of these task there are more chances the feature is included. </p> <p> BTW, alternatively you can provide this hierarchical mutex class as a separated library if you prefer. </p> Ticket anonymous Mon, 18 Aug 2014 08:22:50 GMT <link>https://svn.boost.org/trac10/ticket/8094#comment:2 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/8094#comment:2</guid> <description> <p> Hi Frederick, </p> <p> what kind of license is you code? Am I allowed to use it as i like? Is it the same as thread's (<a href="http://www.boost.org/LICENSE_1_0.txt">http://www.boost.org/LICENSE_1_0.txt</a>) </p> <p> Cheers! </p> <p> Jan </p> </description> <category>Ticket</category> </item> <item> <author>Fredrik Orderud <forderud@…></author> <pubDate>Mon, 18 Aug 2014 10:48:43 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/8094#comment:3 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/8094#comment:3</guid> <description> <p> Yes, feel free to use my code with the Boost license. :-) </p> </description> <category>Ticket</category> </item> <item> <dc:creator>viboes</dc:creator> <pubDate>Sun, 12 Oct 2014 14:34:53 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/8094#comment:4 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/8094#comment:4</guid> <description> <p> Do you mind to provide some documentation and tests and update your code with the Boost license? </p> </description> <category>Ticket</category> </item> <item> <author>Fredrik Orderud <forderud@…></author> <pubDate>Sun, 26 Oct 2014 20:34:05 GMT</pubDate> <title>attachment set https://svn.boost.org/trac10/ticket/8094 https://svn.boost.org/trac10/ticket/8094 <ul> <li><strong>attachment</strong> → <span class="trac-field-new">hierarchical_mutex.7z</span> </li> </ul> <p> Revision as of 2014-10-26 </p> Ticket Fredrik Orderud <forderud@…> Sun, 26 Oct 2014 20:41:49 GMT <link>https://svn.boost.org/trac10/ticket/8094#comment:5 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/8094#comment:5</guid> <description> <p> I've now uploaded a 7-zip archive with an updated hierarchical_mutex implementation. All files are tagged with Boost license information. The archive also contains a tiny test suite, as well as a semi-portable "thread_local" emulation. </p> <p> Feel free to do what ever you want with the implementation. I hope that Boost could consider adopting this pattern in one way or another, since it makes debugging and avoiding deadlocks much easier. </p> </description> <category>Ticket</category> </item> </channel> </rss>