Subject: Re: [Boost-bugs] [Boost C++ Libraries] #11377: Boost condition variable always waits for system clock deadline
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2015-09-08 23:06:18
#11377: Boost condition variable always waits for system clock deadline
-------------------------------------+-------------------------------------
Reporter: Dave Bacher | Owner: viboes
<dbacher@â¦> | Status: assigned
Type: Bugs | Component: thread
Milestone: To Be Determined | Severity: Problem
Version: Boost 1.56.0 | Keywords: condition variable,
Resolution: | clock
-------------------------------------+-------------------------------------
Comment (by Dave Bacher <dbacher@â¦>):
The patch is working properly for me.
With #define BOOST_THREAD_HAS_CONDATTR_SET_CLOCK_MONOTONIC, the test code
waits for the specified duration even with the adjustment of the system
clock. In the output below, the test completes after 5 seconds even though
the system clock was adjusted backwards. Previously, the test would hang
until the system clock reached the time the test was started plus 5
seconds.
{{{
$ sh clock_changes_test.sh
[sudo] password:
Setup sudo authentication
Starting test to wait for 5 seconds
Adjusting time to 01:00:00
Waiting for 5 sec
WAIT_UNTIL
Tue Sep 8 01:00:00 PDT 2015
Waiting...
Steady duration/start/stop: 5
3104032404935 nanoseconds since boot / 3109032558479 nanoseconds since
boot
System duration/start/stop: -52747 seconds
1441751952904865440 nanoseconds since Jan 1, 1970 / 1441699204998073008
nanoseconds since Jan 1, 1970
Test complete, please check your system clock
Tue Sep 8 01:00:05 PDT 2015
}}}
Regarding when to use the monotonic clock, I think there are separate two
issues:
1. Policy -- when should the monotonic clock be used? I would prefer that
using the monotonic clock is the default. But perhaps other applications
have other expectations.
2. Availability -- how to determine if the monotonic clock is available?
On my Linux system, linux/time.h #defines CLOCK_MONOTONIC. At runtime,
[http://linux.die.net/man/3/clock_gettime clock_gettime] returns an error
if the specified clock id is not available.
-- Ticket URL: <https://svn.boost.org/trac/boost/ticket/11377#comment:11> Boost C++ Libraries <http://www.boost.org/> Boost provides free peer-reviewed portable C++ source libraries.
This archive was generated by hypermail 2.1.7 : 2017-02-16 18:50:19 UTC