First post, by romek41
Hello there!
DOSBox has one disadvantage - you have to manually set how many CPU cycles per second it tries to emulate. The problem is, that with some games you can use bigger values for the 'cycles' constant, but another require lower values (or you get choppy sound and games slows down). To find the best 'cycles' value for certain game on your system you have to experiment.
Since I have enough of pressing CTRL+SHIFT+F11 and CTRL+SHIFT+F12, I wrote some code which tries to guess the best 'cycles' value and changes it dynamicaly. It works in a very primitive way:
1. It tries to make the host system CPU usage to be close to 70% - if it is lower - DOSBox can speed up, if it is greater - DOSBox has to slow down.
2. The remaining 30% of the CPU usage is a reserve - it is used when the game suddenly does something, that require more CPU power to emulate.
For me this code seems to work (it may still need some tuning, see the source). However, since it takes the current CPU usage from the proc filesystem, it will only work under Linux (and in the current stage it certainly won't work under Windows). Besides, I'm not sure how will it work on SMP machines and/or modern Pentium IV with HyperThreading enabled - I suppose it won't work as expected. And one more thing: it won't work properly if you run some CPU hungry process in the backgroud - it will look like this:
DOSBox:
- Oh, my. The CPU is 100% busy. I'd better slow down.
Linux kernel:
- Hm, DOSBox does not require that much CPU power. Does anybody want some extra CPU power?
Another CPU Hungry Process:
- Hey, there is still some CPU power left and nobody wants it. I'll take it!
DOSBox:
- Oh, my. The CPU is 100% busy again. I have to slow down again...
And after 1 second or less your DOSBox will run too slow to play.
Roman Standzikowski <romek41 at interia dot pl>