RE: [GD-Windows] More timer fun!
Brought to you by:
vexxed72
From: Phil T. <ph...@mi...> - 2002-08-30 05:34:26
|
Not only will QPC sometimes jump ahead by one to four seconds because of bus traffic, on some processors due to a known manufacturing defect QPC can actually jump backwards and forwards in time significantly. As far as I know this only happens on a small percentage of manufactured CPUs (I have observed it at least once on a P3). This has bitten me in the past. For example one of the programs I debugged had logic that looked something like this: // start timer: __int64 freq; QueryPerformanceFrequency(&freq); __int64 start =3D QueryPerformanceCounter(); =09 // once a frame: if (QueryPerformanceCounter() - start > freq) { // change a state } Basically someone was waiting for a second to elapse before moving on in a state. The program in question was "hung" in a menu waiting to continue. When I hooked up a debugger to this it turned out that QPC would reset (jump backwards) every 6 minutes. The reset just happened to be between the initial call to QPC and before the one second could elapse. Painful indeed, Phil -----Original Message----- From: Jon Watte [mailto:hp...@mi...]=20 Sent: Thursday, August 29, 2002 9:51 PM To: bri...@py...; gam...@li... Subject: RE: [GD-Windows] More timer fun! timGetTime() / GetTickCount() only return 32 bit values, AFAIK. There are some problems with keeping time on PC hardware. timeGetTime()=20 will lag behind wallclock time when there is lots of bus traffic (=3D=3D = graphics-heavy application running). QueryPerformanceCounter() will=20 somtimes jump ahead by 1.3 or 4.1 seconds when there is lots of bus=20 traffic, in a quantum leap. RDTSC ticks once per cycle, but mobile=20 CPUs will adjust their CPU frequency quite often, so you can't get a=20 good bead on that, either. Also, QPC and TGT/GTC each take a bus transaction to execute, and thus=20 run in 1-2 microseconds, which is an eternity if you need to call them=20 more than once or twice per frame rendered. I ended up with an unholy concoction of all three methods, which ends=20 up getting good overall relation to wallclock time, cheap calls, but=20 some local mis-match where my clock will lag behind wall-clock "locally" but get adjusted "globally" when the CPU goes into powersave mode. Yuck. Cheers, / h+ > -----Original Message----- > From: gam...@li... > [mailto:gam...@li...]On Behalf Of > brian hook > Sent: Thursday, August 29, 2002 9:40 PM > To: gam...@li... > Subject: [GD-Windows] More timer fun! >=20 >=20 > Well, in the process of trying to figure out why on a very few systems > (maybe less than 1%) my timing code was messed up, I stumbled across=20 > this tid bit at the Pest Patrol Web site: >=20 > "A Range Check Error can occur on DELL computers running Windows ME=20 > with software using the Windows function GetTickCount. In such systems,=20 > this function is not returning the elapsed time since system power on, > and the value returned can be enormous, causing a range check error.=20 > Dell's Range Check Error affects timeGetTime as well as GetTickCount. A=20 > third timing function, therefore, has been used in PestPatrol,=20 > PestPatrolCL, and PPUpdater." >=20 > Well, sure enough, the two users I know that were having this problem=20 > have Dell Dimension L's with Windows ME. I'm not sure what the=20 > specifics of this problem are (I'm using 64-bit ints already), but I do=20 > some more range checking now and hopefully this problem goes away. >=20 > -Hook >=20 >=20 >=20 > ------------------------------------------------------- > This sf.net email is sponsored by: OSDN - Tired of that same old > cell phone? Get a new here for FREE! > https://www.inphonic.com/r.asp?r=3Dsourceforge1&refcode1=3Dvs3390 > _______________________________________________ > Gamedevlists-windows mailing list > Gam...@li... > https://lists.sourceforge.net/lists/listinfo/gamedevlists-windows > Archives: > http://sourceforge.net/mailarchive/forum.php?forum_id=3D555 >=20 ------------------------------------------------------- This sf.net email is sponsored by: OSDN - Tired of that same old cell phone? Get a new here for FREE! https://www.inphonic.com/r.asp?r=3Dsourceforge1&refcode1=3Dvs3390 _______________________________________________ Gamedevlists-windows mailing list Gam...@li... https://lists.sourceforge.net/lists/listinfo/gamedevlists-windows Archives: http://sourceforge.net/mailarchive/forum.php?forum_id=3D555 |