From owner-freebsd-threads@FreeBSD.ORG Sun Jul 4 21:20:11 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 519D016A4CE for ; Sun, 4 Jul 2004 21:20:11 +0000 (GMT) Received: from duke.cs.duke.edu (duke.cs.duke.edu [152.3.140.1]) by mx1.FreeBSD.org (Postfix) with ESMTP id 10D9343D1D for ; Sun, 4 Jul 2004 21:20:11 +0000 (GMT) (envelope-from gallatin@cs.duke.edu) Received: from grasshopper.cs.duke.edu (grasshopper.cs.duke.edu [152.3.145.30]) by duke.cs.duke.edu (8.12.10/8.12.10) with ESMTP id i64LKAqM013281 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Sun, 4 Jul 2004 17:20:10 -0400 (EDT) Received: (from gallatin@localhost) by grasshopper.cs.duke.edu (8.12.9p2/8.12.9/Submit) id i64LK5lV015002; Sun, 4 Jul 2004 17:20:05 -0400 (EDT) (envelope-from gallatin) From: Andrew Gallatin MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Message-ID: <16616.29829.132376.76817@grasshopper.cs.duke.edu> Date: Sun, 4 Jul 2004 17:20:05 -0400 (EDT) To: freebsd-threads@freebsd.org In-Reply-To: <16613.45444.528419.643022@grasshopper.cs.duke.edu> References: <16613.45444.528419.643022@grasshopper.cs.duke.edu> X-Mailer: VM 6.75 under 21.1 (patch 12) "Channel Islands" XEmacs Lucid Subject: Re: 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: Sun, 04 Jul 2004 21:20:11 -0000 Andrew Gallatin writes: > > The problem happens when exiting. When main application thread > decides to exit, it does an ioctl into the driver to wakeup the > sleeping worker thread. The worker thread thread wakes up, and then > exits, then the main thread closes his file descriptor and exits. > > The problem I'm seeing is that I get a panic like the following when > using KSE. (A linux binary works fine, ioctls are translated..) > The problem turned out to be that the worker thread was sleeping in cv_wait_sig() on a cv which was used elsewhere in the driver. When I fixed this, pretty much everything got better. I still don't understand exactly what happened. I have no idea if the worker woke too early, or if the other place this cv was (mis)used was where the early wake happened. (this would be where mx_free() is called). Anyway, it no longer crashes the machine. Sorry to have wasted your time. Now to figure out why libthr does pthread_cond_signal() in my scenario 47us faster than libpthread... (ULE, 1 HTT P4 running SMP kernel) Scenario is that the mainline thread sleeps waiting for a packet (using pthread_cond_timedwait()) and the worker thread is asleep in kernel. When a packet arrives, the worker wakes up, returns from the ioctl, does a pthread_cond_signal() to wakeup the mainline thread, and goes back into the kernel to sleep (via an ioctl). This is the sort of scenario where I thought KSE would be faster than a 1:1 lib.. Drew