Received: from list by monty-python.gnu.org with tmda-scanned (Exim 4.30) id 1BB9Fh-0001F4-CN for qemu-devel@nongnu.org; Wed, 07 Apr 2004 05:21:45 -0400 Received: from mail by monty-python.gnu.org with spam-scanned (Exim 4.30) id 1BB9BN-0000WT-8I for qemu-devel@nongnu.org; Wed, 07 Apr 2004 05:17:49 -0400 Received: from [199.232.41.8] (helo=mx20.gnu.org) by monty-python.gnu.org with esmtp (TLSv1:DES-CBC3-SHA:168) (Exim 4.30) id 1BB9AZ-0008WM-Na for qemu-devel@nongnu.org; Wed, 07 Apr 2004 05:16:27 -0400 Received: from [80.72.36.106] (helo=alpha.polcom.net) by mx20.gnu.org with esmtp (Exim 4.30) id 1BB8jb-0007XD-Ia for qemu-devel@nongnu.org; Wed, 07 Apr 2004 04:48:35 -0400 Received: from localhost (localhost.lo [127.0.0.1]) by alpha.polcom.net (Postfix) with ESMTP id C36045BE6 for ; Wed, 7 Apr 2004 10:47:30 +0200 (CEST) Received: from alpha.polcom.net ([127.0.0.1]) by localhost (alpha [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 10829-04 for ; Wed, 7 Apr 2004 10:47:27 +0200 (CEST) Received: from localhost (localhost.lo [127.0.0.1]) by alpha.polcom.net (Postfix) with ESMTP id 1090E9F8 for ; Wed, 7 Apr 2004 10:47:27 +0200 (CEST) Date: Wed, 7 Apr 2004 10:47:26 +0200 (CEST) From: Grzegorz Kulewski Subject: Re: [Qemu-devel] Qemu workstation In-Reply-To: <4073BAAC.5070904@wasp.net.au> Message-ID: References: <200404051047.11383.jm@poure.com> <1081156203.3939.10.camel@aragorn> <4071B41F.3040201@bellard.org> <001601c41b57$ed1704f0$6407a8c0@shaggy> <20040406121738.GC2774@linux-m68k.org> <4072B070.3060700@wasp.net.au> <407311D8.5020403@volny.cz> <407384DE.4020900@wasp.net.au> <7992c6b079c0068519527b855dde759e@www3.mail.volny.cz> <4073BAAC.5070904@wasp.net.au> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Reply-To: qemu-devel@nongnu.org List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org 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 parameter. 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. regards Grzegorz Kulewski