qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] Qemu workstation


From: Richard Zidlicky
Subject: Re: [Qemu-devel] Qemu workstation
Date: Wed, 7 Apr 2004 19:50:22 +0200
User-agent: Mutt/1.4i

On Wed, Apr 07, 2004 at 10:47:26AM +0200, Grzegorz Kulewski wrote:
> On Wed, 7 Apr 2004, Brad Campbell wrote:
> 
> > Filip Navara wrote:
> > > Brad Campbell wrote:
> > > 
> > >>How does that work then?
> > > 
> > > 
> > > I don't know the exact details.
> > > 
> > > 
> > >>I have some code that uses a NOP loop for accurate
> > >>timing? That spins at 100% cpu usage, how does a 
> > >>NOP tell the processor to idle? HLT does.
> > > 
> > > 
> > > HLT instruction halts the CPU so no more instructions are
> > > processed and the CPU freezes. That's usable only in situation
> > > like Windows blue screens.
> > 
> > It does? My information tells me that it halts the processor until an 
> > interrupt or other wakeup 
> > source occurs. Check arch/i386/kernel/process.c
> > 
> > /*
> >   * We use this if we don't have any better
> >   * idle routine..
> >   */
> > void default_idle(void)
> > {
> >          if (current_cpu_data.hlt_works_ok && !hlt_counter) {
> >                  __cli();
> >                  if (!current->need_resched)
> >                          safe_halt();
> >                  else
> >                          __sti();
> >          }
> > }
> > 
> > and in include/asm/system.h
> > 
> > system.h:#define safe_halt()            __asm__ __volatile__("sti; hlt": : 
> > :"memory")
> > 
> > Looks like a hlt to me and not a nop in site.
> > The kernel does a check at boot time to see if the processor supports the 
> > hlt instruction and if it 
> > does it uses that in the idle loop.
> > 
> > Am I wrong?
> 
> You are right.
> 
> HLT will block only until interrupt arrives. And there is at least clock 
> interrupt from time to time.

.. anyone remembers the Pentium(tm) "halt" bug ? How should QEMU
emulate that ?;)

it is easy when the guest OS uses hlt of course but a brief look
at some Linux kernel sources suggests there are a few more methods
to do it. Well x86 assembly was never my strong point.

Richard





reply via email to

[Prev in Thread] Current Thread [Next in Thread]