Green DOSBox ;) - dosidle-alike patch

Here you can discuss the development of patches.

Green DOSBox ;) - dosidle-alike patch

Postby h-a-l-9000 » 2010-6-17 @ 18:18

With this patch DOSBox will take only few host CPU when waiting for input i.e. at the command prompt or in a program that calls the idle function (Win 3.11). There might be some side effects but I haven't found any so far.
You do not have the required permissions to view the files attached to this post.
1+1=10
h-a-l-9000
DOSBox Author
 
Posts: 4512
Joined: 2005-2-23 @ 00:14

Re: Green DOSBox ;) - dosidle-alike patch

Postby Dominus » 2010-6-17 @ 21:18

hmm, might have to try that, since Dosbox idles at 20% on OS X :(
User avatar
Dominus
DOSBox Moderator
 
Posts: 7375
Joined: 2002-10-03 @ 09:54
Location: Vienna

Re: Green DOSBox ;) - dosidle-alike patch

Postby robertmo » 2010-6-17 @ 21:27

if i remember correctly in the discussion about high cpu usage in idle dosbox on mac os someone was already trying some simmilar program and it didn't help much.
User avatar
robertmo
l33t
 
Posts: 4160
Joined: 2003-6-18 @ 10:35

Re: Green DOSBox ;) - dosidle-alike patch

Postby DosFreak » 2010-6-17 @ 21:48

Last time I had a cpu issue with DOSBox @ idle (in the CLI with no programs running) it was due to an issue with the renderer. (Was fixed a long time ago). Before the fixed IIRC I had about 30% usage at idle.

Makes since since at idle rendering the video would be the most intensive I suppose.
Game Acronym List
DosBox CVS Builds
DosBox Feature Request Thread
DosBox FAQ
PC Game Compatibility List
"Who's got time to read all the way down to the bottom of an email?"
User avatar
DosFreak
l33t++
 
Posts: 9536
Joined: 2002-6-30 @ 16:35
Location: Your Head

Re: Green DOSBox ;) - dosidle-alike patch

Postby ripsaw8080 » 2010-6-17 @ 21:50

Will the patch help cpuidle work better when DOSBox is running? IIRC, cpuidle uses special instructions to put the CPU into a low-power mode, and it would be nice if the low power and cooling effect of cpuidle was the same with DOSBox sitting at its prompt as Windows sitting at its desktop.
User avatar
ripsaw8080
DOSBox Author
 
Posts: 4121
Joined: 2006-4-25 @ 23:24

Re: Green DOSBox ;) - dosidle-alike patch

Postby h-a-l-9000 » 2010-6-17 @ 23:05

If the CPU usage decreases a lot (while at the command prompt) when increasing frameskip then your computer is indeed struggling with the video and CPU idling inside DOSBox won't help.

The patch uses DOSBox's HLT instruction (fixed/worked around to not lock up with max cycles). The CPU usage on the host drops with max/high fixed cycles that would otherwise start my CPU fan. I can't tell how this works with cpuidle. I think DOSBox still executes every millisecond but does almost nothing each time.
1+1=10
h-a-l-9000
DOSBox Author
 
Posts: 4512
Joined: 2005-2-23 @ 00:14

Re: Green DOSBox ;) - dosidle-alike patch

Postby ripsaw8080 » 2010-6-20 @ 12:26

When waiting for input, DOSBox's INT 16h AH=00h and AH=10h functions have an idle loop that executes some NOP instructions with interrupts enabled. If the idle patch changed the NOPs to INT 28h, the loop added to the console device could be eliminated. This would have a couple of advantages: no additional use of CALLBACK_RunRealInt(), and anything that calls the INT 16h functions directly would also receive the idling benefit. I tried this slight modification to the patch, and it works just as well, with any improvement being more conceptual than perceived.
User avatar
ripsaw8080
DOSBox Author
 
Posts: 4121
Joined: 2006-4-25 @ 23:24

Re: Green DOSBox ;) - dosidle-alike patch

Postby h-a-l-9000 » 2010-6-20 @ 15:44

Hmm this may break if you boot something in DOSBox - I'd rather use HLT instead of NOPs directly.
1+1=10
h-a-l-9000
DOSBox Author
 
Posts: 4512
Joined: 2005-2-23 @ 00:14

Re: Green DOSBox ;) - dosidle-alike patch

Postby ripsaw8080 » 2010-6-20 @ 17:45

I guess putting the HLT in INT 16, whether directly or through an INT 28 call, would be moving the idling into bios when it should be about DOS. ;)

The default INT 28 handler in real DOS is a bare IRET, so having HLT there is not entirely compatible.
User avatar
ripsaw8080
DOSBox Author
 
Posts: 4121
Joined: 2006-4-25 @ 23:24

Re: Green DOSBox ;) - dosidle-alike patch

Postby h-a-l-9000 » 2010-6-20 @ 18:12

It shouldn't matter how the BIOS wastes its time ;)

The side effects I could think of:
- HLT is a privileged instruction that might mess up implementations that use V86
- Programs might expect INT28 to return earlier

Anyway, I don't intend to add it to SVN. Maybe as option in some unofficial build.
1+1=10
h-a-l-9000
DOSBox Author
 
Posts: 4512
Joined: 2005-2-23 @ 00:14

Re: Green DOSBox ;) - dosidle-alike patch

Postby ovvldc » 2010-6-21 @ 23:01

FWIW, I would appreciate any reductions in unneeded cycles.

It isn't that I need them desperately, but it just seems wasteful. Besides, (almost) anything to make computers less noisy is good.

Best wishes,
Oscar
ovvldc
Newbie
 
Posts: 41
Joined: 2008-8-17 @ 12:48
Location: NL

Re: Green DOSBox ;) - dosidle-alike patch

Postby Tobis87 » 2010-8-16 @ 11:19

I tried this slight modification to the patch, and it works just as well, with any improvement being more conceptual than perceived.


Could you share the modified patch with us?
Tobis87
Newbie
 
Posts: 14
Joined: 2010-1-19 @ 18:04

Re: Green DOSBox ;) - dosidle-alike patch

Postby truth_deleted » 2013-9-03 @ 07:39

Updated patch to conform with SVN-r3833. It appears to work well in DOS.
You do not have the required permissions to view the files attached to this post.
truth_deleted
 


Return to DOSBox Patches

Who is online

Users browsing this forum: No registered users and 1 guest