From owner-freebsd-threads@FreeBSD.ORG Tue Jul 6 20:22:41 2004 Return-Path: Delivered-To: freebsd-threads@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id EB15716A4CE for ; Tue, 6 Jul 2004 20:22:41 +0000 (GMT) Received: from mail.pcnet.com (mail.pcnet.com [204.213.232.4]) by mx1.FreeBSD.org (Postfix) with ESMTP id A2D0E43D55 for ; Tue, 6 Jul 2004 20:22:41 +0000 (GMT) (envelope-from eischen@vigrid.com) Received: from mail.pcnet.com (mail.pcnet.com [204.213.232.4]) by mail.pcnet.com (8.12.10/8.12.1) with ESMTP id i66KMYfP010689; Tue, 6 Jul 2004 16:22:34 -0400 (EDT) Date: Tue, 6 Jul 2004 16:22:34 -0400 (EDT) From: Daniel Eischen X-Sender: eischen@pcnet5.pcnet.com To: Andrew Gallatin In-Reply-To: <16619.2082.399880.649617@grasshopper.cs.duke.edu> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII cc: Julian Elischer cc: freebsd-threads@freebsd.org Subject: Re: pthread switch (was Odd KSE panic) X-BeenThere: freebsd-threads@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Threading on FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 06 Jul 2004 20:22:42 -0000 On Tue, 6 Jul 2004, Andrew Gallatin wrote: > > Julian Elischer writes: > > > > > > On Tue, 6 Jul 2004, Andrew Gallatin wrote: > > > > > > > > FWIW, inserting a pthread_yield() just before the ioctl call in the > > > worker thread speeds things up quite a bit (100us -> 73us) in > > > combination with kern.threads.virtual_cpu=1. > > > > what about with kern.threads.virtual_cpu untouched? > > and what about with the hlt sysctl? > > > kern.threads.virtual_cpu=2 > machdep.cpu_idle_hlt=1 > > no yeild 123.6us > yeild 116.8us > > kern.threads.virtual_cpu=2 > machdep.cpu_idle_hlt=0 > no yield 111.9 > yield 112.9 > > kern.threads.virtual_cpu=1 > machdep.cpu_idle_hlt=1 > no yeild 100.8 > yeild 75.0 > > kern.threads.virtual_cpu=1 > machdep.cpu_idle_hlt=0 > no yield 93.9 > ield 67.9 > > > > does your worker thread loop to check if there is more work before > > waiting to be notified? > > Yes. He takes a mutex, loops over all completed events, sending > pthread_signals as required, then releases the mutex and sleeps via > an ioctl. Note that he is holding the mutex while calling pthread_cond_signal(). If we enable preemption in pthread_cond_signal(), then I suspect it would be even worse than without preemption. I think the only place where it is sane to enable preemption is on pthread_mutex_unlock(). -- Dan Eischen