Tomas Hajny wrote:

Thinking back to when people started doing this sort of conversion, as a
general point keep an eye open for any code that loops to poll a key or
e.g. display an on-screen clock. That sort of technique might be fine in
DOS, but as soon as you have a multitasking OS you need to look for
alternatives.

Indeed, good point - SysUtils.Sleep is a better option in this case.
Dos.GetMsCount (suggested in my other response to this thread) still has
its place if you need to check whether at least certain period passed
between two events, etc.

Way back, I was selling and supporting languages and operating systems. Programmers used only to QuickBasic etc. had a major eye-opener when they tried to run multiple copies of their program on CDOS, Desqview, Windows-386 or OS/2 (once it got to the point of supporting multiple dosboxes), and found that almost all the CPU was going into the idle loop which included keyboard and clock polling.

Of course, OSes pretty quickly learnt to detect the common "time wasters" and to put in at least a forcible Yield or Sleep(0). But it's far better not to make a mess in the first place than to rely on somebody else clearing up for you.

--
Mark Morgan Lloyd
markMLl .AT. telemetry.co .DOT. uk

[Opinions above are the author's, not those of his employers or colleagues]
_______________________________________________
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal

Reply via email to