X-Authentication-Warning: delorie.com: mail set sender to djgpp-bounces using -f X-Recipient: djgpp AT delorie DOT com From: "Gerrit van Niekerk" Organization: GPvNO To: djgpp AT delorie DOT com Date: Thu, 27 Mar 2008 15:04:04 +0200 MIME-Version: 1.0 Subject: Strange behaviour of clock() function Message-ID: <47EBB764.17357.14C9089@gerritvn.gpvno.co.za> X-mailer: Pegasus Mail for Windows (4.41) Content-type: text/plain; charset=US-ASCII Content-transfer-encoding: 7BIT Content-description: Mail message body Reply-To: djgpp AT delorie DOT com The clock() function sometimes goes haywire and I isolated the problem to the fact that the _farpeekl(_dos_ds, 0x46c) function sometimes returns a value one less than during a previous invocation of clock(). This is then interpreted as a "midnight passed" event with disastrous effect on the value returned. I have only seen it happen when Real Mode Callbacks are also being used. One event triggering the RMCB is an Int 1cH interrupt. The RMCB function does not call clock(). The environment is ROM-DOS and CWSDPMI. An explanation of why this happens would be appreciated. In the meantime I have solved the problem by testing for a small number of ticks going back in time and just ignoring that value, but I would rather fix the problem than the symptom.