X-Recipient: archive-cygwin AT delorie DOT com X-SWARE-Spam-Status: No, hits=-1.7 required=5.0 tests=AWL,BAYES_00,RCVD_IN_DNSWL_NONE,T_RP_MATCHES_RCVD,UNPARSEABLE_RELAY X-Spam-Check-By: sourceware.org Message-ID: <4F6A5D42.3030108@t-online.de> Date: Wed, 21 Mar 2012 23:59:14 +0100 From: Christian Franke User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:10.0.2) Gecko/20120216 Firefox/10.0.2 SeaMonkey/2.7.2 MIME-Version: 1.0 To: cygwin AT cygwin DOT com Subject: clock_getres(CLOCK_REALTIME, .) may return an outdated and too high resolution Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-IsSubscribed: yes Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cygwin-owner AT cygwin DOT com Mail-Followup-To: cygwin AT cygwin DOT com Delivered-To: mailing list cygwin AT cygwin DOT com clock_getres(CLOCK_REALTIME, &ts) queries the actual resolution through NtQueryTimerResolution (&coarsest, &finest, &actual) during its first call and returns this value unchanged afterwards. This returns a global Windows setting which may be temporarily modified by other applications by using e.g. timeBegin/EndPeriod(). For example playing a flash video in browser sets the resolution to 1ms. It is reset to default ~15ms when the browser is closed. As a consequence the actual resolution might be much lower than reported by clock_getres() when clock_gettime() is used for measurements later. It would IMO be better to return the 'coarsest' instead of the 'actual' value. If clock_setres() is used, this setting should be returned instead of the 'actual' value at the time of the setting. BTW: GetSystemTimeAsFileTime() apparently provides the same resolution (at least on Win7 x64). So the more complex use of SharedUserData.InterruptTime may have less benefit than expected. Christian -- Problem reports: http://cygwin.com/problems.html FAQ: http://cygwin.com/faq/ Documentation: http://cygwin.com/docs.html Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple