🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.os.msdos.programmer
Article #2219

Re: How can I get a timed delay of 1 millisecond ?

#2219
From: Bruce Wright
Date: Fri, 14 Sep 1990 01:30
35 lines
2272 bytes
In article <26ee2f32@ralf>, Ralf.Brown@B.GP.CS.CMU.EDU writes:
> In article <4064@rtifs1.UUCP>, bcw@rti.rti.org (Bruce Wright) wrote:
> }In article <6250@castle.ed.ac.uk>, elee24@castle.ed.ac.uk (H Bruce) writes: 
> }> What is the best way to get a program to wait for one milliosecond ?
> }> (I am using Microsoft C V5.1).
> }
> }The usual way to get a timed delay of one millisecond on the
> }PC is to time a loop that't long enough to take a significant
> }amount of time even on a 486, and then scale that appropriately
> }to execute the loop the proper number of times for your PC.  This
> 
> On ATs and up, you can program the real-time clock chip to generate
> interrupts 1024 times per second, which will get you close to 1ms delays.

Yes, of course.  I _thought_ that was what the entire remainder of
my original article was about;  I may not have been quite clear
enough on what I was talking about.

The main problem with this is with the resolution, depending on how
the timer is programmed.  If you _really_ need a delay of exactly 1 ms,
as might be the case for process control applications, you may find
the facilities in the PC clock chip rather limited (the straight-
forward implementation of a clock that increments/decrements a counter
every time it gets a 1 Hz interrupt is going to result in an error
of up to 1 ms, not counting interrupt latency caused by any other
interrupts that are enabled).  Depending on your application it
_may_ be possible to program the clock with a count for an exact
delta time for an interrupt, but this assumes that you only ever
have one clock running at a time (can't keep track of time very
well except for that one delay).

The best method is going to depend on why the programmer wants a
delay in the first place ...

						Bruce C. Wright
Technical Details
Message-ID: <4070@rtifs1.UUCP>
Path: arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!clyde.concordia.ca!mcgill-vision!snorkelwacker!apple!rutgers!mcnc!rti!bcw
References: <26ee2f32@ralf>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!clyde.concordia.ca!mcgill-vision!snorkelwacker!apple!rutgers!mcnc!rti!bcw
From: bcw@rti.rti.org (Bruce Wright)
Newsgroups: comp.os.msdos.programmer
Subject: Re: How can I get a timed delay of 1 millisecond ?
Summary: Of course ...
Message-ID: <4070@rtifs1.UUCP>
Date: 14 Sep 90 01:30:09 GMT
References: <26ee2f32@ralf>
Organization: Research Triangle Institute, RTP, NC
Lines: 35