slow down qemu - brake
PATCH 1/1 slow 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 PIC interrupt can be missed if PIC raises them 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 usually of several hundreds.
For DOS emulation, where PIC interrupts are raised usually 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
@@ -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
@@ -1177,4 +1177,6 @@void kqemu_record_dump (void ); +extern int brake_mult; +#endif /* VL_H */