QNX: Revert the change to give higher precision timers.

The previous change (SHA 82c2118c) to provide better
than 1ms accuracy for timers on QNX is not safe.

According to the docs, ClockCycles is not guaranteed to
return consistent information if called from different
CPUs.  While this can be addressed by locking the thread
to a single CPU, you wouldn't want to do that here.

On some systems (e.g. BB10) the behavior  is extremely bad
since ClockCycles only has 32 bits of precision.  This
results in overflows in the calculations making short
timers run very slowly (16ms timers were around 1s).  Also
ClockCycles wraps in under three minutes causing even
more problems.

I've talked to the kernel developers and there is currently
nothing that will give you better than 1ms accuracy.  An
individual program could use ClockCycles to calculate more
accurate times if they want.

It's not clear to me what benefit one would get with
increased accuracy.  Unless I've missed something, these
times are only used to calculate timeouts for calls such as
select.  These timeouts will themselves have the same
resolution as clock_gettime provides so the increased
accuracy would appear to be for naught.

Change-Id: Ia38b154ca41949becbd0b8558a9ff4ddd5e01a43
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Bernd Weimer <bweimer@blackberry.com>
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@theqtcompany.com>
Reviewed-by: Rafael Roquetto <rafael.roquetto@kdab.com>
This commit is contained in:
Roger Maclean 2014-12-09 11:44:50 -05:00 committed by Rafael Roquetto
parent 23ba824b7d
commit dec81ad2da

View File

@ -37,10 +37,6 @@
#include "qelapsedtimer.h"
#if defined(Q_OS_VXWORKS)
#include "qfunctions_vxworks.h"
#elif defined(Q_OS_QNX)
#include <sys/neutrino.h>
#include <sys/syspage.h>
#include <inttypes.h>
#else
#include <sys/time.h>
#include <time.h>
@ -88,18 +84,7 @@ QT_BEGIN_NAMESPACE
* see http://pubs.opengroup.org/onlinepubs/9699919799/functions/clock_getres.html
*/
#if defined(Q_OS_QNX)
static inline void qt_clock_gettime(clockid_t clock, struct timespec *ts)
{
// The standard POSIX clock calls only have 1ms accuracy on QNX. To get
// higher accuracy, this platform-specific function must be used instead
quint64 cycles_per_sec = SYSPAGE_ENTRY(qtime)->cycles_per_sec;
quint64 cycles = ClockCycles();
ts->tv_sec = cycles / cycles_per_sec;
quint64 mod = cycles % cycles_per_sec;
ts->tv_nsec = mod * Q_INT64_C(1000000000) / cycles_per_sec;
}
#elif !defined(CLOCK_REALTIME)
#if !defined(CLOCK_REALTIME)
# define CLOCK_REALTIME 0
static inline void qt_clock_gettime(int, struct timespec *ts)
{