Important Notice
The pages on this site contain documentation for very old MS-DOS software,
purely for historical purposes.
If you're looking for up-to-date documentation, particularly for programming,
you should not rely on the information found here, as it will be woefully
out of date.
About Timers (1.2)
◄Using Section► ◄Function Group► ◄Up► ◄Next► ◄Previous►
────────────────────────────────────────────────────────────────────────────
About Timers
This topic describes timers. Timers let programs time events by waiting for
an interval to elapse or by watching for a semaphore to clear. You should
also be familiar with the following topics:
◄Window timers►
◄Multitasking►
◄Interprocess communication►
Since MS OS/2 is a multitasking system, a program never knows when it will
lose execution control or how much time will elapse before control returns.
A timer is a useful and reliable way for a program to count out a given
number of milliseconds. Without timers, a program cannot guarantee that it
can carry out a task after a given interval of time.
Timers are actually managed by the system. When a program requests a timer,
the system monitors the system clock for the program and notifies the
program when the interval elapses.
The system clock keeps a count of the number of system-clock interrupts that
have occurred since the system was started. System-clock interrupts occur
approximately 32 times a second, so timer intervals of less than 50
milliseconds are not recommended. All time values are in milliseconds and
are rounded up to the next clock tick. The duration of the clock tick can be
determined by using the DosGetInfoSeg function and examining the
cusecTimerInterval field in the GINFOSEG structure to which the function
points.
The GINFOSEG structure also contains the current system time. The system
time is the number of milliseconds that have elapsed since the system
started. A process that needs to know the precise time between the start and
the end of a timer can save the system time before starting the timer and
compare that value with the system time after the timer ends. The system
time is reset to zero every few weeks, so a process may need to take this
into account when comparing starting and ending times. The system time may
occasionally lose a millisecond if a process disables interrupts for periods
longer than the clock-tick interval. However, the time of day (hours,
minutes, and seconds), the time in seconds since January 1, 1970, and the
date will remain accurate.
♦