delay

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
pradeep

delay

Post by pradeep »

I am having problem with delay routine. The delay routines in real hardware,bochs and vmware differs. VMware takes a value of 150 for 3 secs delay. Real hardware takes abt 1 sec (or less) for 150. while bochs takes a value of 1000 for 1 sec delay. How am i supposed to have exactly 1 ms delay in all the environments ?
AR

Re:delay

Post by AR »

The emulators have artificially accelerated/decelerated timers to improve performance in the virtual environment, it is not meant to correlate with real timers so you just want the value that you use on real hardware. If you want to support the environments directly then you can either create seperate builds using compile define flags to toggle environment specific timer values or try and detect that you're running in an emulated environment and set the timer on the fly. The latter has no guarantee of success though, the concept of a good emulator is one in which the software cannot [at least reliably] tell it is an emulator.
User avatar
Pype.Clicker
Member
Member
Posts: 5964
Joined: Wed Oct 18, 2006 2:31 am
Location: In a galaxy, far, far away
Contact:

Re:delay

Post by Pype.Clicker »

1. It may worth investigation, but i'd say even if PIT/APIC timers will not be accurate in an emulator, the realtime clock should still display consistent time and raise (if requested) one interrupt per second ...

2. There's indeed a way to tell if you're in an emulated environment or not by looking at how fast the CPU and the CLOCK goes. Clicker does it to set clock rate at 1KHz under real hardware (or emulators that go fast enough to make Clicker believe they're real hardware -- in which case they should be able to run with a 1KHz clock, anyway).

It may be fooled, of course (e.g. believe your 486-SX is an emulator), but all you'll experiment is longer latency from the scheduler ...

Code is at http://cvs.sourceforge.net/viewcvs.py/c ... 3&view=log and is inspirated from some public-domain tool for telling CPU speed, iirc.
Post Reply