|
Boost : |
From: William Linkmeyer (wlink10_at_[hidden])
Date: 2022-06-21 03:08:23
I was under the impression that drift compensation is often hardware supported and extremely accurate (at least for the RTCs Iâve worked on).
WL
> On Jun 20, 2022, at 8:49 PM, Gavin Lambert via Boost <boost_at_[hidden]> wrote:
>
> On 20/06/2022 19:10, Daggumati, Rajesh wrote:
>> When I use boost sleep function, I am getting delayed response.
> [...]
>> output is :
>> 10005
>> 10006
>> Expected ouput should be 10000 and 10000
>
> Sleep time is always a minimum bound, not exact, and is subject to the whims of the OS's thread scheduler. You just have to live with that. Getting less than 10ms "drift" is actually an excellent result; on a loaded system it may be a lot worse than that.
>
> There are some techniques that you can use to try to smooth out sleeps a bit (such as keeping track of the difference between requested and actual delay and adjusting your subsequent request accordingly), but these are rarely necessary (and are impossible to get "perfect" since they're only reactive; and can themselves be the source of bugs, especially in the presence of suspended power states), so they're not recommended for general use.
>
> The best method of compensating for this sort of thing depends on exactly what you're actually trying to do; different goals call for different solutions.
>
> _______________________________________________
> Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk