From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1GshKF-0003dU-VJ for qemu-devel@nongnu.org; Fri, 08 Dec 2006 10:07:47 -0500 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1GshKE-0003dF-4l for qemu-devel@nongnu.org; Fri, 08 Dec 2006 10:07:47 -0500 Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1GshKD-0003dB-Sg for qemu-devel@nongnu.org; Fri, 08 Dec 2006 10:07:46 -0500 Received: from [65.74.133.4] (helo=mail.codesourcery.com) by monty-python.gnu.org with esmtps (TLS-1.0:DHE_RSA_AES_256_CBC_SHA:32) (Exim 4.52) id 1GshKD-0008PU-HA for qemu-devel@nongnu.org; Fri, 08 Dec 2006 10:07:45 -0500 From: Paul Brook Subject: Re: [Qemu-devel] need advice on PCI board emulation Date: Fri, 8 Dec 2006 15:07:40 +0000 References: <1165575170.22384.16.camel@bibi> In-Reply-To: <1165575170.22384.16.camel@bibi> MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <200612081507.40975.paul@codesourcery.com> 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 Friday 08 December 2006 10:52, jerome Arbez-Gindre wrote: > Hi, > > I'm working on a modem PCI board emulation inside Qemu. Qemu already emulates a reasonably modern PCI system. > My emulation is neerly functionnaly complete, but I have some doubt on > my technical choices : > - to emulate dma transfers, I launch one thread for each dma channel. Does this really provide any significant speedup? ie. does qemu spend significant amounts of time doing dma transfers? > - to emulate posponed starting behaviors (board self tests), I launch a > thread with a sleep and then board status changes. You should just use timers. > - to emulate demodulated incoming data, I launch one thread waiting > with blocking reads on a UDP socket. Again, why use threads? > Because I had some toubles (segfaults in tb_reset_jump_recursive2 > (exec.c)), I have serilized my calls to pci_set_irq with the help of a > new thread. > > So, my question is : > Is it reasonable to use threads to emulate parallel behaviors ? Maybe. With the possible exception of processing graphics, I wouldn't expect there to be very limited scope for parallelism in peripheral emulation. Most things are limited by the speed of the underlying device, or how fast the guest CPU can process the data. You're liable to spend more time fighting for locks and waiting for cache flushes bouncing data between different CPUs than you gain from using multiple cores. On single cpu systems (which are still common in low-end machines) using threads is almost certainly going to slow things down. If you look at the current code, you'll notice that most of the operations that can block for a long time waiting for external inputs (IDE/SCSI/USB) already operate asynchronously, and network is fairly asynchronous anyway. Paul