[Top][All Lists]

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

Re: [Qemu-devel] Qemu workstation

From: Grzegorz Kulewski
Subject: Re: [Qemu-devel] Qemu workstation
Date: Wed, 7 Apr 2004 10:47:26 +0200 (CEST)

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.

It helps to cool down the processor too. And autodetection on some 
processors / motherboards is not correct, so there is nohalt kernel 

For blue screens (for me red since I use some tweaker :-) - *no more blue 
screens*(TM)) win probably uses JMP $ or something like that (depending on 
their/your assembler syntax).

And NOP instruction is not good candidate for wasting time anymore on 
newer processrs (since PII I think, maybe later) since processor can 
optimize it out and the only thing that survives that optimization is 
conditional jump, but in cache, so latency is very small.


Grzegorz Kulewski

reply via email to

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