cvs.gedasymbols.org/archives/browse.cgi   search  
Mail Archives: djgpp/1999/08/12/21:05:18

From: ryot AT bigfoot DOT com (George Ryot)
Newsgroups: comp.os.msdos.djgpp
Subject: Re: uclock() and Integer
Message-ID: <37b3e739.5241020@news.clara.net>
References: <Pine DOT SUN DOT 3 DOT 91 DOT 990811145631 DOT 19078C-100000 AT is>
X-Newsreader: Forte Agent 1.5/32.452
X-No-Archive: yes
MIME-Version: 1.0
Date: Thu, 12 Aug 1999 15:32:56 GMT
NNTP-Posting-Host: 195.8.92.177
X-Complaints-To: abuse AT clara DOT net
X-Trace: nnrp3.clara.net 934471976 195.8.92.177 (Thu, 12 Aug 1999 16:32:56 BST)
NNTP-Posting-Date: Thu, 12 Aug 1999 16:32:56 BST
Lines: 35
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp
Reply-To: djgpp AT delorie DOT com

Eli Zaretskii <eliz AT is DOT elta DOT co DOT il> wrote:

> Let me guess: you are running this on Windows 9X, right?
> 
> If so, then the problem is that `uclock' reprograms the system timer when 
> you call it the first time, and Windows does not update the actual timer 
> device with the new mode until the next timer tick.  So, during the first 
> timer tick interval after the first call to `uclock', the timer still 
> works in its original mode, before it was reprogrammed, and confuses the 
> computations inside `uclock'.
> 
> In DJGPP v2.03, `uclock' was changed to wait until the timer ticks when 
> it is called for the first time.  This solves the problem.  As a 
> work-around, you can do the same in your code, like this:
> 
>    int otics;
>    uclock ();
>    _farsetsel(_dos_ds);
>    otics = _farnspeekl(0x46c);
>    do {
>      errno = 0;
>      __dpmi_yield();   /* will set errno to ENOSYS on plain DOS */
>    } while (errno == 0 && _farnspeekl(0x46c) == otics);
> 
>    uclock ();

The following code seems to work fine on W95 :

    uclock();            /* Initialise the timer */
    while(clock() == 0); /* Wait for first tick  */
        
    while(!(kbhit()))    /* Loop until keypress  */
        printf("%Ld\n", uclock());
-- 
george

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019