<< Previous Message Main Index Next Message >>
<< Previous Message in Thread This Month Next Message in Thread >>
Date   : Fri, 19 Aug 2005 20:12:34 +0100
From   : Tom Seddon <tom@...>
Subject: Re: BeebEm bug?

Richard_Talbot-Watkins@... wrote:
> Tom, I've also noticed that Model B runs at 99% on my home PC (or 49% on my
> work PC which has hyperthreading on its single CPU), and I also wondered if
> this needed to be the case.  I wonder what BeebEm 2.2 is doing to be able
> to cut its CPU use down to 10%?  Is it possible to Sleep() the process for
> the few microseconds required, rather than stalling it with a delay loop?
> (I am not a Windows programmer so I have no idea if sleeping for such a
> small amount of time is possible...)

I'd had very poor results (fairly random speed limiting in particular) 
when trying that kind of thing originally. Windows only lets processes 
sleep in increments of 1ms, and it's fairly sloppy about the amount of 
time they're suspended for. But it turns out that's just what BeebEm 
does, so I tried again -- turns out all you need is another call 
(timeBeginPeriod) to tighten up the system timer resolution for the 
current process. Once I'd done that, it all worked much better: and now, 
speed limited, with sound, model-b takes up about 35% CPU time on my 
650MHz Pentium III PC running WIndows 2000.

(Interestingly, beebem doesn't make this call, so I'm not at all sure 
how it works! It could be down to its running the windows message loop 
more frequently than model-b, which only does it 25 times per second.)

This timing 'trick' isn't officially documented as far as I'm aware, but 
apparently it works across all Windows versions. So, it's staying in, 
and will be present in the next version... whenever that comes out. (I 
just really haven't had the time or inclination to tie up the loose ends 
  and get a new version ready for release. I'll be honest -- it's much 
more fun adding new stuff :)

--Tom
<< Previous Message Main Index Next Message >>
<< Previous Message in Thread This Month Next Message in Thread >>