Boost logo

Threads-Devel :

Subject: Re: [Threads-devel] Fwd: cond.timed_wait() returns way after deadline?
From: Frank Mori Hess (frank.hess_at_[hidden])
Date: 2009-07-09 09:06:59


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On Thursday 09 July 2009, Stefan Steuerwald wrote:
> Dear threaders,
>
> I have this code:
>
>        unique_lock<mutex> lock(mut);
>        system_time deadline = get_system_time() + timeout;
>        while( some_pred() ) {
>                if( ! cond.timed_wait( lock, deadline ) )
>                        break;
>        }
>
> boost 1.37.0 on a linux 2.6.30.1 kernel.
> Works fine 99% of the time. Sometimes however, I see timed_wait()
> returning several seconds AFTER the deadline (timeout is 5000ms).
> I wonder what could cause such behaviour?

You didn't show the notify end of the code. Does it lock the same mutex
before calling notify?

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (GNU/Linux)

iEYEARECAAYFAkpV63QACgkQ5vihyNWuA4XodgCeLttkJLBfSlM26tiScpauimdW
xAwAoMtyi1uL7MWxvFYcKmIRo/sLaQw3
=SAn9
-----END PGP SIGNATURE-----


Threads-Devel list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk