VOGONS


First post, by romek41

User metadata
Rank Newbie
Rank
Newbie

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>

Attachments

  • Filename
    adjust.cpp.gz
    File size
    1018 Bytes
    Downloads
    193 downloads
    File license
    Fair use/fair dealing exception

Reply 1 of 3, by MiniMax

User metadata
Rank Moderator
Rank
Moderator

Perhaps if your background job gets a healthy dose of nice(1), and DOSBox a healthy dose of not-so-nice, it will work out better?

DOSBox 60 seconds guide | How to ask questions
_________________
Lenovo M58p | Core 2 Quad Q8400 @ 2.66 GHz | Radeon R7 240 | LG HL-DT-ST DVDRAM GH40N | Fedora 32

Reply 2 of 3, by Darkfalz

User metadata
Rank Member
Rank
Member

It's not possible to devote any CPU time to getting the sync/sound/video done, and then devote the rest of the time in the timeslice to doing as many cycles as possible, or something like that?

Reply 3 of 3, by miargep

User metadata
Rank Newbie
Rank
Newbie

I think the general problem here is that dosbox cannot know when the dos-program is really doing something sensible or just waiting for time to pass (or if the dos program runs at 300 frames/sec). dos programs typically don't signal information about their state.