From 76d3346630a3f3a111d06819a96c97fa13e9b760 Mon Sep 17 00:00:00 2001 From: Fons Rademakers <Fons.Rademakers@cern.ch> Date: Mon, 5 Feb 2007 10:38:04 +0000 Subject: [PATCH] From Gerri: this patch sets the timer resolution in such a way that it is 10ms for timeouts <= 200s and 5 / 100000 of timeout for longer timeouts. There is no magic behind this fraction: it just gives 10ms at 200s and it covers with some margin the drift we observe on the CAF for 1h delays (117 ms vs 36 * 5 = 180ms). With this change things on the CAF work fine. git-svn-id: http://root.cern.ch/svn/root/trunk@17688 27541ba8-7e3a-0410-8455-c3a389f83636 --- base/src/TTimer.cxx | 12 ++++++++++-- unix/src/TUnixSystem.cxx | 5 +++-- winnt/src/TWinNTSystem.cxx | 4 ++-- 3 files changed, 15 insertions(+), 6 deletions(-) diff --git a/base/src/TTimer.cxx b/base/src/TTimer.cxx index c2e8802a3e8..0394c56d05e 100644 --- a/base/src/TTimer.cxx +++ b/base/src/TTimer.cxx @@ -1,4 +1,4 @@ -// @(#)root/base:$Name: $:$Id: TTimer.cxx,v 1.14 2006/07/09 05:27:53 brun Exp $ +// @(#)root/base:$Name: $:$Id: TTimer.cxx,v 1.15 2006/07/26 13:36:42 rdm Exp $ // Author: Fons Rademakers 28/11/96 /************************************************************************* @@ -124,7 +124,15 @@ Bool_t TTimer::CheckTimer(const TTime &now) { // Check if timer timed out. - if (fAbsTime <= now) { + // To prevent from time-drift related problems observed on some dual-processor + // machines, we make the resolution proportional to the timeout period for + // periods longer than 200s, with a proportionality factor of 5*10**-5 + // hand-calculated to ensure 10ms (the minimal resolution) at transition. + TTime xnow = TMath::Max((ULong_t)kItimerResolution, + (ULong_t) (0.05 * (ULong_t)fTime)); + xnow += now; + + if (fAbsTime <= xnow) { fTimeout = kTRUE; Notify(); return kTRUE; diff --git a/unix/src/TUnixSystem.cxx b/unix/src/TUnixSystem.cxx index d14c1a36cc9..f36a9e3a919 100644 --- a/unix/src/TUnixSystem.cxx +++ b/unix/src/TUnixSystem.cxx @@ -1,4 +1,4 @@ -// @(#)root/unix:$Name: $:$Id: TUnixSystem.cxx,v 1.178 2007/01/30 15:38:36 rdm Exp $ +// @(#)root/unix:$Name: $:$Id: TUnixSystem.cxx,v 1.179 2007/02/05 09:41:09 rdm Exp $ // Author: Fons Rademakers 15/09/95 /************************************************************************* @@ -2523,7 +2523,8 @@ Bool_t TUnixSystem::DispatchTimers(Bool_t mode) Bool_t timedout = kFALSE; while ((t = (TTimer *) it.Next())) { - Long_t now = UnixNow()+kItimerResolution; + // NB: the timer resolution is added in TTimer::CheckTimer() + Long_t now = UnixNow(); if (mode && t->IsSync()) { if (t->CheckTimer(now)) timedout = kTRUE; diff --git a/winnt/src/TWinNTSystem.cxx b/winnt/src/TWinNTSystem.cxx index c75d6311a94..9dece9ac964 100644 --- a/winnt/src/TWinNTSystem.cxx +++ b/winnt/src/TWinNTSystem.cxx @@ -1,4 +1,4 @@ -// @(#)root/winnt:$Name: $:$Id: TWinNTSystem.cxx,v 1.161 2007/01/30 15:38:36 rdm Exp $ +// @(#)root/winnt:$Name: $:$Id: TWinNTSystem.cxx,v 1.162 2007/02/05 09:41:09 rdm Exp $ // Author: Fons Rademakers 15/09/95 /************************************************************************* @@ -3619,8 +3619,8 @@ Bool_t TWinNTSystem::DispatchTimers(Bool_t mode) Bool_t timedout = kFALSE; while ((t = (TTimer *) it.Next())) { + // NB: the timer resolution is added in TTimer::CheckTimer() TTime now = Now(); - now += TTime(kItimerResolution); if (mode && t->IsSync()) { if (t->CheckTimer(now)) { timedout = kTRUE; -- GitLab