c++.dos.16-bits - Implementation of a delay() function
- Catatonic Porpoise (12/12) Jan 12 2003 For a while, I have been writing programs in Borland Turbo C++ 3.0, and
-
Jeff Peil
(10/22)
Jan 12 2003
#include
- Catatonic Porpoise (2/9) Jan 18 2003 Thanks. I didn't expect it to be so convenient.
- KarL (7/19) Jan 12 2003 My personal way of doing "good" time/synchronisation on
- Catatonic Porpoise (4/10) Jan 18 2003 Is this more accurate than functions such as msleep()? I unfortunately
- B.L. Gaino (11/11) Dec 09 2004 implementaion 2
- Alfgaar (3/3) Dec 10 2006 It works perfectly! Wonderfully!
For a while, I have been writing programs in Borland Turbo C++ 3.0, and I had become used to its delay() function (defined in DOS.H, if I recall correctly), so I was distraught to learn that DMC++ does not contain one. This function takes one argument, the time to pause in milliseconds. I have tried to write such timer functions in the past, with very little success. Could anyone suggest a 'clean' and accurate way of implementing a delay() function similar to that of TC++? Any help would be greatly appreciated. Except for the lack of delay(), which can hardly be called a fault, I have had only good experiences with DMC++ and plan to get the CD version in the near future. Thanks, Catatonic 'Graue' Porpoise
Jan 12 2003
"Catatonic Porpoise" <graue fojar.donotsendspam.com> wrote in message news:avr99b$b8j$2 digitaldaemon.comFor a while, I have been writing programs in Borland Turbo C++ 3.0, and I had become used to its delay() function (defined in DOS.H, if I recall correctly), so I was distraught to learn that DMC++ does not contain one. This function takes one argument, the time to pause in milliseconds. I have tried to write such timer functions in the past, with very little success. Could anyone suggest a 'clean' and accurate way of implementing a delay() function similar to that of TC++? Any help would be greatly appreciated. Except for the lack of delay(), which can hardly be called a fault, I have had only good experiences with DMC++ and plan to get the CD version in the near future. Thanks, Catatonic 'Graue' Porpoise#include <time.h> int main() { long nMillis = 10000; msleep(nMillis); } -- Jeff Peil
Jan 12 2003
Jeff Peil wrote:#include <time.h> int main() { long nMillis = 10000; msleep(nMillis); }Thanks. I didn't expect it to be so convenient.
Jan 18 2003
My personal way of doing "good" time/synchronisation on DOS-16 is to install a Interrupt driver on Int8 and reprogram the Timer to generate interrupt at a resolution close to the delay required and restore after using it. This will make it more "hardware" oriented. "Catatonic Porpoise" <graue fojar.donotsendspam.com> wrote in message news:avr99b$b8j$2 digitaldaemon.com...For a while, I have been writing programs in Borland Turbo C++ 3.0, and I had become used to its delay() function (defined in DOS.H, if I recall correctly), so I was distraught to learn that DMC++ does not contain one. This function takes one argument, the time to pause in milliseconds. I have tried to write such timer functions in the past, with very little success. Could anyone suggest a 'clean' and accurate way of implementing a delay() function similar to that of TC++? Any help would be greatly appreciated. Except for the lack of delay(), which can hardly be called a fault, I have had only good experiences with DMC++ and plan to get the CD version in the near future. Thanks, Catatonic 'Graue' Porpoise
Jan 12 2003
KarL wrote:My personal way of doing "good" time/synchronisation on DOS-16 is to install a Interrupt driver on Int8 and reprogram the Timer to generate interrupt at a resolution close to the delay required and restore after using it. This will make it more "hardware" oriented.Is this more accurate than functions such as msleep()? I unfortunately don't know the hardware well enough to do any of that. -Catatonic 'Graue' Porpoise
Jan 18 2003
"Catatonic Porpoise" <graue fojar.donotsendspam.com> wrote in message news:b0djpo$2ekg$2 digitaldaemon.com...KarL wrote:It is the "Resolutions" or "granularity" of the timer. I think you get about 55ms accuracy in DOS or Windows. The documentations says: ------------------------------ void msleep(long milliseconds); Description Suspends execution of the program for the specified number of milliseconds. The granularity depends on the operating system.My personal way of doing "good" time/synchronisation on DOS-16 is to install a Interrupt driver on Int8 and reprogram the Timer to generate interrupt at a resolution close to the delay required and restore after using it. This will make it more "hardware" oriented.Is this more accurate than functions such as msleep()? I unfortunately don't know the hardware well enough to do any of that.
Jan 20 2003
KarL wrote:"Catatonic Porpoise" <graue fojar.donotsendspam.com> wrote in message news:b0djpo$2ekg$2 digitaldaemon.com...right. afaik on DM msleep is based on int 21h fc 2Ch dos function witch depend on int 1ch interrupt witch depend on int 8 interrupt witch is ( supposed to be ) called each 55ms by the i8254 0 timer. it is possible to have a better resolution using int 15h function 86h witch depend on the rtc MC146818 and have a resolution of 976 micosecond. the best resolution is obtained using asm rdtsc instruction, supported by DM. rolandKarL wrote:It is the "Resolutions" or "granularity" of the timer. I think you get about 55ms accuracy in DOS or Windows.My personal way of doing "good" time/synchronisation on DOS-16 is to install a Interrupt driver on Int8 and reprogram the Timer to generate interrupt at a resolution close to the delay required and restore after using it. This will make it more "hardware" oriented.Is this more accurate than functions such as msleep()? I unfortunately don't know the hardware well enough to do any of that.
Jan 21 2003
implementaion 2 I am not sure this works int delay(int millisec) { clock_t timesec; timesec = clock(); while((clock() - timesec) < millisec) { } return millisec; }
Dec 09 2004
It works perfectly! Wonderfully! Cool... Yer great! :)
Dec 10 2006