New TIMER0.SYS and CLOCK01.SYS, the why and how....

Note, this page is primarily for the software developers. In all cases read the documentation carefully!

 This driver set was written to overcome a major problem with the TIMER0.SYS high-resolution timer driver that is
 shipped with Warp 4 and higher.

 In the original TIMER0.SYS, the hardware counter-0 is used to provide a free-running counter generating interrupts
 at 1ms resolution. To do this it must effectively detach counter-0 from DOS VDMs as DOS also makes use of
 counter-0 to generate its timer tick interrupt. Owing to the possible demands of VDMs to require direct access to
 counter-0, it becomes necessary to deny them access to counter-0 while a TIMER0.SYS client is active. It is thus
 impossible for VDMs to receive timer-tick interrupts while TIMER0 is in use. This has ramifications for most DOS
 (and hence WinOS/2) MIDI programs where the generic WinOS/2 audio and Soundblaster emulation interface is
 concerned as this interface will not work in conjunction with any OS/2 audio MIDI PDD that uses TIMER0. Once the
 OS/2 audio MIDI PDD is opened, TIMER0 is opened and VDMs no longer receive timer tick interrupts - so the DOS
 or WinOS/2 MIDI player running in the session no longer has any timing info and can no longer send data. RTMIDI
 uses TIMER0 and suffers from the same limitation.

 (Status at 25th of October, a new version of the generic WIN/OS2 driver will be released soon on this webpage.
  SB emulation for in DOS sessions is on the schedule for the next release).

 To fix this, it is necessary to find an alternative to the use of counter-0 for the generation of the high-resolution
 timer interrupts. VDMs hit counter-0 directly, with access mediated by VTIMER.SYS, and DOS sets the timer
 frequency on boot.

 There are, however, two timer-based interrupts available in an OS/2 system. One is the counter-0 interrupt
 discussed previously. The second is the periodic interrupt generated by the real-time clock hardware and handled in
 CLOCK01.SYS. This interrupt handler is responsible both for updating some of the timer-based kernel variables, and
 also for providing callbacks to the kernel at 8Hz and 32Hz. The kernel uses these to aid in process scheduling.

 It is possible to change the rate of the RTC interrupt. However, it is not possible to change this to exactly 1ms.
 The 8Hz/32Hz kernel callback rates should be preserved - it is thus possible to reprogram the RTC to generate
 interrupts at 1024Hz, a convenient multiple of 32 and 8Hz. Modifications to the RTC interrupt handler allow the
 system millisecond count to now be updated more frequently while preserving the kernel callback rates. Furthermore,
 the IRQ thread can be redirected into a new TIMER0.SYS which can provide 1/1024Hz resolution or via a simple
 resampling technique, 1ms resolution.



The new TIMER0.SYS offers:

 The new TIMER0.SYS included in this package has been written from the ground-up as a new implementation of the
 high-resolution timer and is not based upon the original TIMER0.SYS. It does not affect the VDM timer, and provides
 up to ten virtual independent timers which can individually support resolutions of 1/1024s or 1ms resampled.

 It supports two different API models: compatibility model and extended model. In the first model full compatibility is
 retained with the original TIMER0, and TIMER0 clients will not need modification to work with the new TIMER0.
 The second model can co-exist with the first and provides a handle-based API to the virtual independent timers
 accessible in any execution context.



The new CLOCK01.SYS

 This driver has been updated and the RTC interrupt code modified as described in  the design objectives  and a
 small number of improvements made to the structure of the code to clean it up somewhat. A protocol has been added
 to allow communication between the new TIMER0.SYS and CLOCK01.SYS. Note, however, that all existing
 communications mechanisms have been retained in the modified CLOCK01.SYS, and the original TIMER0.SYS will
 work with the new CLOCK01.SYS in the original manner (i.e. without the fix).

Note on CLOCK02.SYS
 An updated CLOCK02.SYS has not been developed and is not included in this release. It is believed that this driver
 only supports some legacy hardware (Microchannel machines). However, if you need it then please contact me and let
 me know. If enough people require it then I will update this as well.



Don't mix up versions

 IT IS EXTREMELY IMPORTANT not to mix versions of the components of this driver, or unpredictable results may
 occur. There is a utility supplied with the driver set called VERSION. To display the version of any component of all
 releases of this driver, simply use the command VERSION <filename>, where the <filename> is the filename of the
 component you wish to check. Version number, build ID and component name will be displayed. If a message 'No
 version information in this file' is displayed you probably are running VERSION against the original TIMER0.SYS or
 CLOCK01.SYS, or if unlucky have a corrupted file.

 Compatibility has been fully retained in CLOCK01.SYS. The new CLOCK01.SYS is fully compatible with the
 original TIMER0.SYS and will cause no ill-effects in such an arrangement. If the new TIMER0.SYS is used in
 conjunction with the old CLOCK01.SYS however, the high resolution timer driver will simply not work. Neither
 configuration will result in a system trap.



Download!

Last but not least it is important to place a BIG credit note here!
I (Roderick Klein) run this website, but John Gow does the real work, he programs the code!
Click here to send an email to John Gow

Click here to download the latest version... (version of 26th of October 2000)