[Last Call] Learn about multicloud storage options and how to improve your company's cloud strategy. Register Now

x
?
Solved

Microsecond timing routine for DOS

Posted on 1997-08-18
2
Medium Priority
?
382 Views
Last Modified: 2008-03-10
Please help me to find an algoritm to provide software delays accurate to plus or minus 10 microseconsds and able to generate delays fo the order of  1.2 to 2.5 milliseconds.
0
Comment
Question by:paas
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 4

Accepted Solution

by:
emmons earned 100 total points
ID: 1253333
The problem is going to be that the clock on the machine generates ticks on the order of 1 per millisecond (check out the system value CLOCKS_PER_SEC). This means that millisecond timing is easy. Microsecond, not so much.
For a millisecond level timer a quick way might be to put in a
loop to check the timer upon occasion until the correct time has passed. .

#include <time.h>
/* give begintime and endtime the type */
/* returned by clock(): clock_t on my system */
clock_t begintime, endtime;
float totaltime; /* in seconds */
endtime = begintime = clock();
for( totaltime = 0;  
      (endtime - begintime) < 100    /* 100 ms */;
      endtime = clock()
      );

If you really need microsecond timing, there is a company that sells a library that does it. Check out
http://www.ryledesign.com/winhrt.html
0
 

Author Comment

by:paas
ID: 1253334
Dear Emmons,
I really do need microsecond timing to get accurate delays of 1.2 and 2.5 milliseconds.  I am presently using a softrware delay loop written in assembler and trying to calibrate it automatically by calling it  multiple times (say 1.2 mS * 5000 = 6 seconds) and adjusting its loop counter until I get the right answer.

BTW there is a website called 'snippets' which has such software but I have not been able to assemble their timer.  Also Borland offer a millisecond timer (delay (unsigned milliseconds)] as a part of their runtime library.
Pls excuse the return advice flow!!!

Many thanks,

Andy
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This tutorial is posted by Aaron Wojnowski, administrator at SDKExpert.net.  To view more iPhone tutorials, visit www.sdkexpert.net. This is a very simple tutorial on finding the user's current location easily. In this tutorial, you will learn ho…
This is a short and sweet, but (hopefully) to the point article. There seems to be some fundamental misunderstanding about the function prototype for the "main" function in C and C++, more specifically what type this function should return. I see so…
The goal of this video is to provide viewers with basic examples to understand and use structures in the C programming language.
The goal of this video is to provide viewers with basic examples to understand how to use strings and some functions related to them in the C programming language.

656 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question