TEvent.WaitFor on *nix uses Realtime Clock, and not the Monotonic Clock
Original Reporter info from Mantis: benjamin@0ok.de @bero1985
-
Reporter name: Benjamin Rosseaux
Original Reporter info from Mantis: benjamin@0ok.de @bero1985
- Reporter name: Benjamin Rosseaux
Description:
The TEvent.WaitFor stuff at FPC is probably wrong at the moment, because it uses the Realtime Clock and not the Monotonic Clock, see https://bugs.python.org/issue23428 and https://linux.die.net/man/3/pthread_condattr_setclock and https://stackoverflow.com/questions/14248033/clock-monotonic-and-pthread-mutex-timedlock-pthread-cond-timedwait.
I suspect that we are, because we have to set monotonic-clock (if it is not default), also have to fix the freepascal code to use monotonic clock. Theoretically there should also be cond_relative_timed_wait, but I have not find much about that.
(And it is a bad design to make a timeout as absolute time in this case.)
Accordingly I have attached an appropriate patch here.
Steps to reproduce:
- Compile test0.pas without my patch, run it, set your realtime clock backwards and/or forwards in the time, and see what then happens.
- And then compile test0.pas with my patch, run it, set your realtime clock backwards and/or forwards in the time, and see what then happens in the contrast.