From owner-freebsd-hackers@FreeBSD.ORG Mon Apr 21 22:50:22 2008 Return-Path: Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id B4A4D106566C for ; Mon, 21 Apr 2008 22:50:22 +0000 (UTC) (envelope-from julian@elischer.org) Received: from outF.internet-mail-service.net (outf.internet-mail-service.net [216.240.47.229]) by mx1.freebsd.org (Postfix) with ESMTP id A35B08FC1A for ; Mon, 21 Apr 2008 22:50:22 +0000 (UTC) (envelope-from julian@elischer.org) Received: from mx0.idiom.com (HELO idiom.com) (216.240.32.160) by out.internet-mail-service.net (qpsmtpd/0.40) with ESMTP; Tue, 22 Apr 2008 05:40:39 -0700 Received: from julian-mac.elischer.org (localhost [127.0.0.1]) by idiom.com (Postfix) with ESMTP id 10A4A2D6006; Mon, 21 Apr 2008 15:50:21 -0700 (PDT) Message-ID: <480D1A2F.2000605@elischer.org> Date: Mon, 21 Apr 2008 15:50:23 -0700 From: Julian Elischer User-Agent: Thunderbird 2.0.0.12 (Macintosh/20080213) MIME-Version: 1.0 To: "Murty, Ravi" References: <480CF0F2.20609@elischer.org> <480CFA15.9050807@elischer.org> In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Cc: freebsd-hackers@freebsd.org Subject: Re: Do you really "sleep" when blocked on a mutex? X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 21 Apr 2008 22:50:22 -0000 Murty, Ravi wrote: > That's actually what I was trying to get to. > > If I look at vm_daemon(), it checks to see if every thread of the > process is running, on the runq or sleeping. If any threads fails the > condition - and I can think of the case where a thread is blocked > waiting for a lock - it is not a target to be swapped out. I guess this > means that if a thread is holding a lock, it can be swapped out. no. because if it holds a lock it must be in the run queue, running or waiting for another lock. no other state is permitted. > How > does this guarantee that the thread is not holding a kernel lock? Why > don't they allow threads waiting for a lock (blocked threads/processes) > to be swapped out? > > Related question: how can a process/thread running on a CPU be swapped > out, do they suspend the threads before they pull out memory from > underneath them? not sure, I'd have to read the code again. > > Thanks > Ravi >