www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1997/05/05/10:30:37

From: mauch AT uni-duisburg DOT de (Michael Mauch)
Newsgroups: comp.os.msdos.djgpp
Subject: Re: testing uclock()
Date: Mon, 05 May 1997 12:31:19 +0200
Organization: Home, sweet home (via Gesamthochschule Duisburg)
Lines: 131
Distribution: world
Message-ID: <336ea503.189123@news.uni-duisburg.de>
References: <Pine DOT SUN DOT 3 DOT 91 DOT 970504133340 DOT 9215E-100000 AT is>
NNTP-Posting-Host: ppp91.uni-duisburg.de
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

On Sun, 4 May 1997 10:34:10 GMT, Eli Zaretskii <eliz AT is DOT elta DOT co DOT il>
wrote:

> > On the other hand: isn't it possible that this default mode is just
> > the same as the one set by the first call to uclock()? The
> > difference between two consecutive calls to uclock() remains the
> > same, even after that single negative difference.
> 
> No, you can't work with the default mode at all.  Under that mode, the
> timer counter goes up and down twice during the 54 msec period, so you
> cannot reliably compute the interval.

Oh, that's bad.
 
> > I removed the first three outportb() calls from the uclock source
> > code, and now I don't get any negative differences anymore.
> 
> I think that is specific to the time that your test program waited
> between two calls to `uclock'.  Try different intervals and you will
> see the problem again.

Yes, you are right, unfortunately.

In the meantime I translated my 16 bit source code to work with DJGPP. 
It uses the Virtual Timer Device of Win3.1/Win95 if this is available,
otherwise it calls the original uclock(). Although it seems to work, I'm
not sure how accurate it is - as much as we can expect timing accuracy
in Windows. I looked at the output of a test program (with different
intervals, this time) using gnuplot, and it shows up that it is a lot
slower than uclock(), and there are a lot of peaks (some of them up to
60000 tics, i.e. 50ms), but there a no negative values anymore.

Another question is, if there is a wrap-around anywhere (there's none at
midnight). Ralf Brown's Interrupt List says that the VTD API gives the
time since Windows was started, so there should be a long time before
the 63 bit signed long long (returned in edx:eax by the VTD API call)
would need a wrap around. But you never know.

And I don't know why the original uclock() source uses __bss_count (what
is __bss_count?):

  if (uclock_bss != __bss_count)
  {
    /* timer chip initialization here */
    uclock_bss = __bss_count;
  }

Is it simply a flag to do the initialization only once or what's the
magic with __bss_count?

Regards...
		Michael


begin 644 Puclock.h
M(VEF;F1E9B!054-,3T-+7T@-"B-D969I;F4 AT 4%5#3$]#2U](#0H-"B-I;F-L
M=61E(#QT:6UE+F@^#0H-"F5X=&5R;B!U8VQO8VM?="`H*G!U8VQO8VLI*'9O
0:60I.PT*#0HC96YD:68-"F5X
`
end

begin 644 Puclock.c
M(VEN8VQU9&4@/'-T<FEN9RYH/@T*(VEN8VQU9&4@/&1P;6DN:#X-"@T*(VEN
M8VQU9&4@(G!U8VQO8VLN:"(-"@T*<W1A=&EC('5C;&]C:U]T('=U8VQO8VM?
M=W)A<'!E<BAV;VED*3L-"@T*=6-L;V-K7W0@*"IP=6-L;V-K*2AV;VED*2`]
M('=U8VQO8VM?=W)A<'!E<CL-"@T*#0HO*B`-"BHJ('=U8VQO8VLH*2!W;W)K
M<R!J=7-T(&QI:V4@=6-L;V-K*"DL('1H870@:7,Z#0HJ*@T**BH@(E1H:7,@
M9G5N8W1I;VX@<F5T=7)N<R!T:&4@;G5M8F5R(&]F('5C;&]C:R!T:6-K<R!S
M:6YC92!A;B!A<F)I=')A<GD-"BHJ("!T:6UE+"!A8W1U86QL>2P@<VEN8V4@
M=&AE(&9I<G-T(&-A;&P@=&\@8'5C;&]C:R<L('=H:6-H(&ET<V5L9B!R971U
M<FYS#0HJ*B`@>F5R;RX@(%1H92!N=6UB97(@;V8@=&EC<R!P97(@<V5C;VYD
M(&ES(%5#3$]#2U-?4$527U-%0RXB#0HJ*B`H<75O=&5D(&9R;VT@;&EB8RYI
M;F8I+@T**BH-"BHJ('=U8VQO8VLH*2!Q=65R:65S('1H92!6:7)T=6%L(%1I
M;65R($1E=FEC92`H5E1$*2!O9B!7:6YD;W=S(#,N,2`O(%=I;CDU+@T**BH@
M4F%L9B!"<F]W;B=S($EN=&5R<G5P="!,:7-T('-A>7,@=&AA="!T:&4 AT 5E1$
M(')E='5R;G,@=&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<FX@<'5C;&]C:R`]('=U8VQO8VLL
,('([#0I]#0H-"@T*
`
end

- Raw text -


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