I have the following problem: I need a way to make my delphi 3 program
wait
x microseconds before continuing with the next operation, similar to the
borland
command delay(n) where n of course is in milliseconds, not micros.
Does any of you know a way of timing delphi programs in this way ?
Thank you very much in advance,
Peter.
--
--------------------------------------------------------------
Dr. Peter Uhd Jepsen
Department of Molecular and Optical Physics
University of Freiburg
Hermann-Herder-Str. 3
D-79104 Freiburg
email: jep...@uni-freiburg.de
www: http://frhewww.physik.uni-freiburg.de/~puhd/homepage
--------------------------------------------------------------
HTH,
Conor
Peter Uhd Jepsen <jep...@uni-freiburg.de> wrote in message
news:391AA98E...@uni-freiburg.de...
but the important fact is that above function
is based on busy waiting and so it blocks
other processes from taking the CPU time.
Otherwise when you call Win32 Sleep API function,
OS preempts your process(current calling process)
and give CPU time to other waiting process.
It is very difficult to develop microseconds or even
miliseconds based time-critical applications on
Windows 98/NT, because its target is not realtime
OS.
you can get more detailed information from MSDN library.
bye
Find out the speed of the current processor. (from the registry?)
Calculate the number of operations (cycles) it can do within a millisecond.
600mhz -> 600,000,000 oper/sec?
then create a loop something like this (it has been a while since I used
assembler...)
maxloop := mhz / 2
asm
di //disable interrupts (dangerous)
mov EAX, maxloop
@start
dec EAX //needs 1 cycle
jnz start //needs 1 cycle
ei //enable interrupts
end
I think the timing will be loosy, but it's a start...
"Peter Uhd Jepsen" <jep...@uni-freiburg.de> wrote in message
news:391AA98E...@uni-freiburg.de...
> Hello Delphi people:
>
> I have the following problem: I need a way to make my delphi 3 program
> wait
> x microseconds before continuing with the next operation, similar to the
> borland
> command delay(n) where n of course is in milliseconds, not micros.
>
> Does any of you know a way of timing delphi programs in this way ?
>
> Thank you very much in advance,
> Peter.
>
Conor
Conor Boyd <conor....@nospam.zonal.co.uk> wrote in message
news:yZAS4.1832$vg5.2...@news3.cableinet.net...
> Afraid I'm not familiar with delay(n), but would the
> Windows.Sleep(milliseconds) function not do what you want?
>
> HTH,
>
> Conor
>
Thank you for the answers, I'll try out the options...