Somebody's ears were burning... ;-)

Co-incident with our discussion about the hz_timer, I just saw this come
in from the Bochs list.  Not quite the same issue, but along the same
lines.

Excess CPU usage by virtualised environments seems to be an issue in more
places than we might expect.

Cheers,
Vic

--
Vic Cross  MACS
Linux, Networking, on zSeries and S/390


---------- Forwarded message ----------
Date: Thu, 12 Jun 2003 03:14:34 -0700
From: SourceForge.net <[EMAIL PROTECTED]>
To: [EMAIL PROTECTED]
Subject: [bochs - bochs-developers] Reduce CPU Usage in Win32


Read and respond to this message at:
https://sourceforge.net/forum/message.php?msg_id=2057340
By: rvjcallanan

I created this unofficial patch for pit_wrap.cpp module in Bochs 2.0.2. Please
insert just after following existing code:

#ifdef BX_SCHEDULED_DIE_TIME
  if (bx_pc_system.time_ticks() > BX_SCHEDULED_DIE_TIME) {
    BX_ERROR (("ticks exceeded scheduled die time, quitting"));
    BX_EXIT (2);
  }
#endif

**************** PATCH ****************
#if BX_WITH_WIN32

  static int sleep_ticks = 0;

  // 100% CPU usage is undesirable especially with notebooks because battery
consumption
  // increases dramatically and CPU fans kick in. It also slows down responsiveness
of
  // other applications running on your Windows desktop. At the same time, we
don't want to
  // reduce emulator performance. The BX_USE_IDLE_HACK is only for an X11 host
and
  // only works when halt instruction is encountered. This assumes that all
activity is
  // triggered by interrupts - this may be so for sophisticated operating systems
but is
  // certainly not the case with DOS. My approach puts Bochs to sleep at regular
intervals
  // based on system time ticks (just as if host OS had suspended Bochs in favour
of another
  // task so it should not affect emulation stability). The advantage of this
method is that,
  // when emulator is stressed, system ticks will slow down and suspends will
happen less
  // frequently which means maximum performance is still achievable. I've chosen
a 1mS sleep
  // every 80 ticks, which translates to about 3% CPU usage during low emulation
loads
  // climbing to over 90% with heavy loads (this was calibrated on a 1200MHz
Celeron Notebook)
  // If experimenting, I would advise in the interests of responsiveness, not
to increase
  // sleep duration (it is already at it's minimum of 1mS) and be warned that
idle CPU usage
  // jumps up very quickly if you increase sleep_ticks threshold above current
value. You
  // should also avoid using the --enable-slowdown config option. In fact this
code reduces
  // the PIT race ahead problem during low emulator loads so you shouldn't need
this option.

  // WARNING: This patch was implemented to suit my own purposes and is not
in the official
  // Bochs release - [EMAIL PROTECTED] - 12th June 2003

  sleep_ticks += 1;

  if (sleep_ticks >= 80)
  {
    Sleep(1);
        sleep_ticks = 0;
  }

#endif

 ************* END OF PATCH ************

______________________________________________________________________
You are receiving this email because you elected to monitor this forum.
To stop monitoring this forum, login to SourceForge.net and visit:
https://sourceforge.net/forum/monitor.php?forum_id=127786

Reply via email to