Back to home page

DOS ain't dead

Forum index page

Log in | Register

Back to the forum
Board view  Mix view

modern timers in DOS (32bit) (Developers)

posted by bretjohn Homepage E-mail, Rio Rancho, NM, 06.05.2022, 20:01

> I´m thinking of a lapic timer or perhaps the hpet, and yes I would like to
> generate interrupts at a specific frequency. I fully understand that on a
> PC the timer interrupts are not that precise than on other "platforms".

Those kinds of timers can indeed be used to generate interrupts. For experimental/private purposes that can be OK, but since they only exist on some computers (they are not very "universal") I personally wouldn't normally use them. As others have indicated, they may not even work (at least correctly) in at least some Virtual Machines.

What I normally use is the RTC (IRQ 8/INT 70h) which is programmable through the CMOS. It is programmable to generate interrupts from 2 Hz up to 8192 Hz in factors of 2^n (2, 4, 8, 16, ...) with the default of 1024 Hz. As mceric indicated, it's not used by too many programs so you can reprogram it to something other than 1024. I would still avoid reprogramming it, though. I use it in some of my programs and even though it would be "nice" to reprogram it I don't because of the potential issues it CAN cause when the program is not in complete control of everything. That's also why I never reprogram the PIC timer for IRQ 0 (INT 8).

>> If you're just wanting to "monitor" the frequency and don't require
>> hardware notifications (interrupts) at each tick of the clock, that can
>. use a different approach.
>
> You are thinking of the time stamp counter or ?

The TSC is one way, but again that's less "universal" than using something like the PIC counter (which is what Japheth's code uses). The PIC counter has a resolution of about a microsecond, which is more than sufficient for most applications.

There are also"tricks " you can play with things like USB host controllers. The USB bus has its own "ecosystem" and timers and you can sometimes tap into those timers if you're careful. You really can't use the USB host hardware to generate interrupts "on demand" (though my USB drivers have an "extension" that allows you to do it). But you can use the USB hardware to "monitor" time durations.

 

Complete thread:

Back to the forum
Board view  Mix view
22049 Postings in 2034 Threads, 396 registered users, 84 users online (1 registered, 83 guests)
DOS ain't dead | Admin contact
RSS Feed
powered by my little forum