Skip to contentSkip to conversation

intentinoal slowing down qemu - brake

PATCH In review Miroslav Novak 6 participants 10 messages Nov 30, 2006 – Dec 6, 2006

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 intentinoal slowing down qemu - brake

This patch adds support for slowing down qemu and saving cpu load.
The '-brake' command line parameter or monitor command 'brake' determines how long to wait in the main_loop with respect to duration of time that qemu used for the emulation itself. Thus e.g. zero value runs at full speed, 1 at 1/2 speed, 10 at 1/11 speed, etc.

A drawback of this approach is that the timer interrupt can be missed if raised too often. This happens if the loop_main divided by (1+brake) is less than the frequency of PIC interrupts. In such case the time of emulated system runs slowly.

This problem occurs mainly for Linux emulation where kernel parameter HZ is of several hunderds.
For DOS emulation, where the timer interrupts are raised usualy at 18Hz, this approach works nice, and one can play old DOS games at reasonable speed and save batteries.

Mirek

monitor.c renamed from ../orig/qemu-0.8.2/monitor.c +10 -0
diff -aur ../../orig/qemu-0.8.2/monitor.c ./monitor.c
@@ -276,6 +276,14 @@
         term_printf("Invalid CPU index\n");
 }
 
+static void do_brake_set(int multiplier)
+{
+    if (multiplier < 0)
+        term_printf("Current brake multiplier %d\n", brake_mult);
+    else
+        brake_mult = multiplier;
+}
+
 static void do_info_jit(void)
 {
     dump_exec_info(NULL, monitor_fprintf);
@@ -1198,6 +1206,8 @@
 #endif
      { "stopcapture", "i", do_stop_capture,
        "capture index", "stop capture" },
+    { "brake", "i", do_brake_set, 
+      "multiplier", "set brake multiplier (non-negative integer), negative value prints actual setting" },
     { NULL, NULL, }, 
 };
 
vl.c renamed from ../orig/qemu-0.8.2/vl.c +78 -0

128 lines not on this page · raw message

vl.h renamed from ../orig/qemu-0.8.2/vl.h +2 -0
diff -aur ../../orig/qemu-0.8.2/vl.h ./vl.h
@@ -1177,4 +1177,6 @@
 
 void kqemu_record_dump(void);
 
+extern int brake_mult;
+
 #endif /* VL_H */
#1 lore raw
Quoted 1 line

This patch adds support for slowing down qemu and saving cpu load.

Poooooooooooooooo!

if you're using the right kernel, QEMU will sleep while there is nothing to be done.
Otherwise just nice -10 it.

Voto contra

M

#2 lore raw

Then again, if someone needed it... it's not as if I have to use it...

M

#3 lore raw
In reply to Martin Guy

Hi,

Quoted 4 lines · Martin Guy
Quoted 1 line

This patch adds support for slowing down qemu and saving cpu load.

if you're using the right kernel, QEMU will sleep while there is nothing to be done.

As was stated by the OP, this is for DOS games. So, there is no "nothing to be done". Further, you are assuming everybody uses Linux. What makes you think so?

Besides, your "nice" would not do the same thing, you know? You'd need _another_ tast _using_ the CPU to slow down QEmu. Which would burn through the battery like hell.

Ciao,
Dscho

#4 lore raw

SoftICE under DOS16, anybody? __/__ Re: [Qemu-devel] [PATCH] intentinoal slowing down qemu - brake

Quoted 12 lines · Johannes Schindelin
Quoted 7 lines
Quoted 3 lines

This patch adds support for slowing down qemu and saving cpu load.

if you're using the right kernel, QEMU will sleep while there is nothing to be done.

As was stated by the OP, this is for DOS games. So, there is no "nothing to be done". Further, you are assuming everybody uses Linux. What makes you think so?

Quoted 8 lines

Besides, your "nice" would not do the same thing, you know? You'd need _another_ tast _using_ the CPU to slow down QEmu. Which would burn through the battery like hell.

Ciao,
Dscho

Might something like that help SoftICE for DOS16 to run properly without freezing the whole guest after one or two ^D's (i.e. for setting breakpoints and switching back to the dos command.com)?
WinICE (on DOS386 a.k.a. {win386.exe / chicago's dos386.exe, now called vmm32.vxd}) does/did already work well, when I last tested this a year ago, but SoftICE for real mode DOS would always hang the whole guest when being run inside QEMU (emulation case, not yet tested in case of x86_x_x86 virtualization).
The same happens when using the Insignia_SoftWindows Pentium-ISA-PC Emulator on Solaris_sparc, running any version of (MS-/IBM) or DRDOS. Bochs claims to provide a more accurate emulation than qemu (at the cost of making it marginally slower), but doesn't fix the SoftICE issue either.

It does - on the other hand - work as expected inside any version of SunPCi, which only emulates a bit of io and graphics, but uses a physical x86 cpu, rather than emulating it (I think it doesn't even have to virtualize it, because nobody else is using the cpu sitting on that pci card).

Has onybody found a way to work around the SoftICE_for_DOS16 instabilities under qemu?
(btw, my problems *are* qemu-dependant, not caused by an incompatible himem.sys or anything of that sort / identical diskimages tested under SunPCi, SoftWindows and qemu_for_SolarisSPARC-Hosts).

Thanks,
Maddin

#5 lore raw

Re: SoftICE under DOS16, anybody? __/__ Re: [Qemu-devel] [PATCH] intentinoal slowing down qemu - brake

Quoted 25 lines · Martin Bochnig
Quoted 25 lines

Might something like that help SoftICE for DOS16 to run properly without freezing the whole guest after one or two ^D's (i.e. for setting breakpoints and switching back to the dos command.com)?
WinICE (on DOS386 a.k.a. {win386.exe / chicago's dos386.exe, now called vmm32.vxd}) does/did already work well, when I last tested this a year ago, but SoftICE for real mode DOS would always hang the whole guest when being run inside QEMU (emulation case, not yet tested in case of x86_x_x86 virtualization).
The same happens when using the Insignia_SoftWindows Pentium-ISA-PC Emulator on Solaris_sparc, running any version of (MS-/IBM) or DRDOS. Bochs claims to provide a more accurate emulation than qemu (at the cost of making it marginally slower), but doesn't fix the SoftICE issue either.

It does - on the other hand - work as expected inside any version of SunPCi, which only emulates a bit of io and graphics, but uses a physical x86 cpu, rather than emulating it (I think it doesn't even have to virtualize it, because nobody else is using the cpu sitting on that pci card).

Has onybody found a way to work around the SoftICE_for_DOS16 instabilities under qemu?
(btw, my problems *are* qemu-dependant, not caused by an incompatible himem.sys or anything of that sort / identical diskimages tested under SunPCi, SoftWindows and qemu_for_SolarisSPARC-Hosts).

Quoted 4 lines
Quoted 4 lines

Thanks,
Maddin

I might some remote day invest a bit of effort into trying to find out WHY exactly SoftICE_for_realmodeDOS hangs the emulation (under qemu, bochs and SoftWindows/RealPC) :
Whether or not it freezes "somehow internally" because of "actually running", or, more specifically, whether it just has to do with listening to the keyboard for "^D" sequences (int16h and int21h_AH==01 / see Ralf Brown's grand Interrupt list) to activate the SoftICE UI. If it is "just" the latter, then maybe due to a timing related problem, or maybe because the SoftICE-TSR somehow interferes with COMMAND.COM (or any shell like i.e. BASH_for_DOS or 4DOS.COM) that are concurrently listening to kbd input and therefore actively issuing certains DOS-21h and 16h interrupts permanently (with appropriate values in (E)AL, (E)AL, or(E)AX, permanently requesting the keyboard, if it has new input in its associated stdin buffer (not quite correct, simplified).

The issue applies to all major SoftICE_for_realmodeDOS releases/versions.

Thanks.

--
Martin

#6 lore raw
In reply to Miroslav Novak

I'm sending some more facts that should make clear why I think the functionality provided by the patch is relevant. (At least for the DOS emulation.)

Making emulated CPU slower
Some old DOS games runs too fast on modern CPUs, even the qemu-emulted
ones. This patch can make these games playable.
This was reported in http://qemu-forum.ipi.fi/viewtopic.php?t=1264

Energy saving
MSDOS doesn't use HLT insn. Even if the dosidle can help in command
prompt, it doesn't work in other programs such as games.
This was reported in http://qemu-forum.ipi.fi/viewtopic.php?t=1372

The similar approach is used in dosbox by setting "CPU cycles". I think qemu is better than dosbox, so it makes sense to me to include such capability too.

This patch doesn't try to emulate the task scheduler that was why Martin voted against it. I'm sorry if I wasnt't clear enough in my first post.

Mirek.

Quoted 22 lines · Miroslav Novak

This patch adds support for slowing down qemu and saving cpu load. The '-brake' command line parameter or monitor command 'brake' determines how long to wait in the main_loop with respect to duration of time that qemu used for the emulation itself.
Thus e.g. zero value runs at full speed, 1 at 1/2 speed, 10 at 1/11 speed, etc.

A drawback of this approach is that the timer interrupt can be missed if raised too often. This happens if the loop_main divided by (1+brake) is less than the frequency of PIC interrupts.
In such case the time of emulated system runs slowly.

This problem occurs mainly for Linux emulation where kernel parameter HZ is of several hunderds.
For DOS emulation, where the timer interrupts are raised usualy at 18Hz, this approach works nice, and one can play old DOS games at reasonable speed and save batteries.

Mirek

#7 lore raw
In reply to Miroslav Novak

I'm sending some more facts that should make clear why I think the functionality provided by the patch is relevant. (At least for the DOS emulation.)

Making emulated CPU slower
Some old DOS games runs too fast on modern CPUs, even the qemu-emulted
ones. This patch can make these games playable.
The problem was reported in http://qemu-forum.ipi.fi/viewtopic.php?t=1264

Energy saving
MSDOS doesn't use HLT insn. Even if the dosidle can help in command
prompt, it doesn't work in other programs such as games.
This was reported in http://qemu-forum.ipi.fi/viewtopic.php?t=1372

The similar approach is used in dosbox by setting "CPU cycles". I think qemu is better than dosbox, so it makes sense to me to include such capability too.

This patch doesn't try to emulate the task scheduler that was why Martin voted against it. I'm sorry if I wasnt't clear enough in my first post.

Mirek.

Quoted 22 lines · Miroslav Novak

This patch adds support for slowing down qemu and saving cpu load. The '-brake' command line parameter or monitor command 'brake' determines how long to wait in the main_loop with respect to duration of time that qemu used for the emulation itself.
Thus e.g. zero value runs at full speed, 1 at 1/2 speed, 10 at 1/11 speed, etc.

A drawback of this approach is that the timer interrupt can be missed if raised too often. This happens if the loop_main divided by (1+brake) is less than the frequency of PIC interrupts.
In such case the time of emulated system runs slowly.

This problem occurs mainly for Linux emulation where kernel parameter HZ is of several hunderds.
For DOS emulation, where the timer interrupts are raised usualy at 18Hz, this approach works nice, and one can play old DOS games at reasonable speed and save batteries.

Mirek

#8 lore raw

Hi,

We are faceing one Problem in Qemu guest os winxp . The Qemu hbas been installed in Linux CentOs 4.4 . Guest os detected the Realtek Lan Adapter . BUt with is Adpeter we are unable get the IP from Our Dhcp Server. Could you suggest how to do this.

Regards
Manish

Quoted 67 lines · Miroslav Novak

I'm sending some more facts that should make clear why I think the functionality provided by the patch is relevant. (At least for the DOS emulation.)

Making emulated CPU slower
Some old DOS games runs too fast on modern CPUs, even the qemu-emulted
ones. This patch can make these games playable.
The problem was reported in
http://qemu-forum.ipi.fi/viewtopic.php?t=1264

Energy saving
MSDOS doesn't use HLT insn. Even if the dosidle can help in command
prompt, it doesn't work in other programs such as games.
This was reported in http://qemu-forum.ipi.fi/viewtopic.php?t=1372

The similar approach is used in dosbox by setting "CPU cycles". I think qemu is better than dosbox, so it makes sense to me to include such capability too.

This patch doesn't try to emulate the task scheduler that was why Martin voted against it. I'm sorry if I wasnt't clear enough in my first post.

Mirek.

Quoted 2 lines · Miroslav Novak

This patch adds support for slowing down qemu and saving cpu load. The '-brake' command line parameter or monitor command 'brake'

determines how

Quoted 1 line

long to wait in the main_loop with respect to duration of time that qemu

used

Quoted 2 lines

for the emulation itself.
Thus e.g. zero value runs at full speed, 1 at 1/2 speed, 10 at 1/11

speed,

Quoted 4 lines

etc.

A drawback of this approach is that the timer interrupt can be missed if raised too often. This happens if the loop_main divided by (1+brake) is

less

Quoted 4 lines

than the frequency of PIC interrupts.
In such case the time of emulated system runs slowly.

This problem occurs mainly for Linux emulation where kernel parameter HZ

is of

Quoted 2 lines

several hunderds.
For DOS emulation, where the timer interrupts are raised usualy at 18Hz,

this

Quoted 1 line

approach works nice, and one can play old DOS games at reasonable speed

and

Quoted 6 lines

save batteries.

Mirek

_______________________________________________
Qemu-devel mailing list
[email protected]
http://lists.nongnu.org/mailman/listinfo/qemu-devel

#9 lore raw

Network problem, was Re: [Qemu-devel] [PATCH] intentinoal slowing down qemu - brake

Hi,

please do not reply to something completely unrelated.

Quoted 4 lines · Manish Gajbhiye

We are faceing one Problem in Qemu guest os winxp . The Qemu hbas been installed in Linux CentOs 4.4 . Guest os detected the Realtek Lan Adapter . BUt with is Adpeter we are unable get the IP from Our Dhcp Server.

The network card QEmu detects is a _virtual_ one. And it should already have received an IP by the _virtual_ DHCP in QEmu. The _virtual_ router inside QEmu will act as a masquerading firewall to your QEmu instance, so that network connections to the wide world will seem to originate from your _host_ machine.

Hth,
Dscho