Boost C++ Libraries: Ticket #6377: Condition variable blocks when changing time https://svn.boost.org/trac10/ticket/6377 <p> I am using Linux on an ARM system, running Boost 1.47. My application needs accurate timing, and for this I use a POSIX timer using SIGRTMIN. This part is not something that I can control, it is an external library that implements this. I use condition variables as a timing mechanism within my software. </p> <p> When I use condition variables without the POSIX timer there is no problem. The timing continues correctly, even if I change the time forward or backward. </p> <p> When I start the POSIX timer the condition variable does not time-out when I change the time backward. It only times out when the original time (plus timeout) is reached. </p> <p> When I changed the clock of the pthread condition variable to monotonic (call to pthread_condattr_setclock(&amp;condattr, CLOCK_MONOTONIC)) the result was OK again. </p> <p> Attached is a test application that shows the problem and implements a solution. This solution is not within the Boost library but directly as a POSIX condition variable. Options to the test application: </p> <pre class="wiki">-b: use boost condition variable -s: generate POSIX signals </pre><p> When running the testapplication with -bs the application will stop reporting when the time is changed backwards. When the time is set back to a time after the time the time was changed the application will continue. </p> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/6377 Trac 1.4.3 Johan Borkhuis <johan@…> Wed, 11 Jan 2012 09:56:22 GMT attachment set https://svn.boost.org/trac10/ticket/6377 https://svn.boost.org/trac10/ticket/6377 <ul> <li><strong>attachment</strong> → <span class="trac-field-new">clocktest.cpp</span> </li> </ul> <p> Demo application showing the problem </p> Ticket Johan Borkhuis <johan@…> Wed, 11 Jan 2012 11:03:03 GMT owner, component changed https://svn.boost.org/trac10/ticket/6377#comment:1 https://svn.boost.org/trac10/ticket/6377#comment:1 <ul> <li><strong>owner</strong> changed from <span class="trac-author">Ion Gaztañaga</span> to <span class="trac-author">Anthony Williams</span> </li> <li><strong>component</strong> <span class="trac-field-old">interprocess</span> → <span class="trac-field-new">thread</span> </li> </ul> Ticket anonymous Thu, 26 Apr 2012 19:43:04 GMT <link>https://svn.boost.org/trac10/ticket/6377#comment:2 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/6377#comment:2</guid> <description> <p> I also have the same issue. </p> </description> <category>Ticket</category> </item> <item> <dc:creator>viboes</dc:creator> <pubDate>Sat, 07 Jul 2012 15:26:49 GMT</pubDate> <title>owner, status changed https://svn.boost.org/trac10/ticket/6377#comment:3 https://svn.boost.org/trac10/ticket/6377#comment:3 <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> </ul> <p> Boost.Thread provides timed functions based on a Boost.Chrono. Using the steady_clock should solve your problem. The legacy time-based functions will be deprecated soon. Please let me know if this solves your problem. </p> Ticket viboes Sun, 08 Jul 2012 16:08:11 GMT status changed; resolution set https://svn.boost.org/trac10/ticket/6377#comment:4 https://svn.boost.org/trac10/ticket/6377#comment:4 <ul> <li><strong>status</strong> <span class="trac-field-old">assigned</span> → <span class="trac-field-new">closed</span> </li> <li><strong>resolution</strong> → <span class="trac-field-new">wontfix</span> </li> </ul> Ticket viboes Sun, 08 Jul 2012 16:08:25 GMT milestone deleted https://svn.boost.org/trac10/ticket/6377#comment:5 https://svn.boost.org/trac10/ticket/6377#comment:5 <ul> <li><strong>milestone</strong> <span class="trac-field-deleted">To Be Determined</span> </li> </ul> Ticket viboes Thu, 03 Sep 2015 20:56:34 GMT status changed; milestone set; resolution deleted https://svn.boost.org/trac10/ticket/6377#comment:6 https://svn.boost.org/trac10/ticket/6377#comment:6 <ul> <li><strong>status</strong> <span class="trac-field-old">closed</span> → <span class="trac-field-new">reopened</span> </li> <li><strong>resolution</strong> <span class="trac-field-deleted">wontfix</span> </li> <li><strong>milestone</strong> → <span class="trac-field-new">To Be Determined</span> </li> </ul> <p> I'm writing a patch that uses pthread_condattr_setclock. As I said I have no platform providing it (I'm using MacOS). The user will need to define BOOST_THREAD_HAS_CONDATTR_SET_CLOCK_MONOTONIC until I find a way to detect it. </p> <p> Is there any one that can test it? </p> Ticket viboes Thu, 03 Sep 2015 21:45:53 GMT milestone changed https://svn.boost.org/trac10/ticket/6377#comment:7 https://svn.boost.org/trac10/ticket/6377#comment:7 <ul> <li><strong>milestone</strong> <span class="trac-field-old">To Be Determined</span> → <span class="trac-field-new">Boost 1.60.0</span> </li> </ul> <p> Add to develop branch <a class="ext-link" href="https://github.com/boostorg/thread/commit/9f883f6ad7377b88b79fa70cc5de68cbfb0213e4"><span class="icon">​</span>https://github.com/boostorg/thread/commit/9f883f6ad7377b88b79fa70cc5de68cbfb0213e4</a> </p> Ticket viboes Sat, 05 Sep 2015 14:20:27 GMT status changed https://svn.boost.org/trac10/ticket/6377#comment:8 https://svn.boost.org/trac10/ticket/6377#comment:8 <ul> <li><strong>status</strong> <span class="trac-field-old">reopened</span> → <span class="trac-field-new">new</span> </li> </ul> Ticket viboes Sat, 05 Sep 2015 14:23:01 GMT milestone changed https://svn.boost.org/trac10/ticket/6377#comment:9 https://svn.boost.org/trac10/ticket/6377#comment:9 <ul> <li><strong>milestone</strong> <span class="trac-field-old">Boost 1.60.0</span> → <span class="trac-field-new">To Be Determined</span> </li> </ul> Ticket viboes Tue, 08 Sep 2015 19:43:27 GMT status changed https://svn.boost.org/trac10/ticket/6377#comment:10 https://svn.boost.org/trac10/ticket/6377#comment:10 <ul> <li><strong>status</strong> <span class="trac-field-old">new</span> → <span class="trac-field-new">assigned</span> </li> </ul> Ticket viboes Fri, 25 Sep 2015 05:41:43 GMT milestone changed https://svn.boost.org/trac10/ticket/6377#comment:11 https://svn.boost.org/trac10/ticket/6377#comment:11 <ul> <li><strong>milestone</strong> <span class="trac-field-old">To Be Determined</span> → <span class="trac-field-new">Boost 1.60.0</span> </li> </ul> <p> Please, could you try the develop branch </p> <p> <a class="ext-link" href="https://github.com/boostorg/thread/commit/8f5de1d7c34ff7248261874f273498a622bf76d4"><span class="icon">​</span>https://github.com/boostorg/thread/commit/8f5de1d7c34ff7248261874f273498a622bf76d4</a> </p> Ticket viboes Sun, 27 Sep 2015 13:36:13 GMT status changed; resolution set https://svn.boost.org/trac10/ticket/6377#comment:12 https://svn.boost.org/trac10/ticket/6377#comment:12 <ul> <li><strong>status</strong> <span class="trac-field-old">assigned</span> → <span class="trac-field-new">closed</span> </li> <li><strong>resolution</strong> → <span class="trac-field-new">fixed</span> </li> </ul> <p> <a class="ext-link" href="https://github.com/boostorg/thread/commit/730cb550e6d969520c3f39e0ddf5d80351bddf3a"><span class="icon">​</span>https://github.com/boostorg/thread/commit/730cb550e6d969520c3f39e0ddf5d80351bddf3a</a> </p> Ticket