From owner-freebsd-hackers@FreeBSD.ORG Tue Apr 22 00:03:29 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 26883106566C for ; Tue, 22 Apr 2008 00:03:29 +0000 (UTC) (envelope-from asmrookie@gmail.com) Received: from fg-out-1718.google.com (fg-out-1718.google.com [72.14.220.158]) by mx1.freebsd.org (Postfix) with ESMTP id ADCAE8FC1B for ; Tue, 22 Apr 2008 00:03:28 +0000 (UTC) (envelope-from asmrookie@gmail.com) Received: by fg-out-1718.google.com with SMTP id 16so2125772fgg.35 for ; Mon, 21 Apr 2008 17:03:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:message-id:date:from:sender:to:subject:cc:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references:x-google-sender-auth; bh=cm/5jhPhFCPYPqJwGlwRS7z6hbhjbDapFq2keQfbGHw=; b=tqO8lnsJoITkq2RbrcOpeSTlDIRH+BqDVMRGmPdTn+P5Xr/adRfkIdGMsYe6xw+PYwUh5iKy7wgDl/HjDWPj9Y7gmYhMOzLm7kWKiTO49I1/Hh0f610b8fkb28/2PIdoTp8f1CDISciWtTr7cgtyIUyhs8k6aB2hIX5Q7ZvTKRs= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:sender:to:subject:cc:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references:x-google-sender-auth; b=JDM83S18o3lVbgMRZMqabwFtbsOtHHDdn75ESWLXwJApNoAnYYmPHkTh2ete5mR5kyY6Hv1YoaKOG3QutRM1wIfGmkDbNU0f4srhhT1IwfEnJOAK32QM3wHr3YJeXjlubJH+E6yok86RX9A8c4wK56CADP9evWGVJfC6KeIqlR4= Received: by 10.86.73.7 with SMTP id v7mr6485277fga.31.1208822607288; Mon, 21 Apr 2008 17:03:27 -0700 (PDT) Received: by 10.86.36.15 with HTTP; Mon, 21 Apr 2008 17:03:27 -0700 (PDT) Message-ID: <3bbf2fe10804211703h6eebbde2q2054a30df1e0164b@mail.gmail.com> Date: Tue, 22 Apr 2008 02:03:27 +0200 From: "Attilio Rao" Sender: asmrookie@gmail.com To: "Murty, Ravi" In-Reply-To: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit Content-Disposition: inline References: X-Google-Sender-Auth: 37245f2f7782917e 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: Tue, 22 Apr 2008 00:03:29 -0000 2008/4/21, Murty, Ravi : > Hello, > > > > When a thread cannot get a mutex (default mutex) and needs to be > blocked, is it really put to sleep? From looking at the code it appears > that it is inhibited (TD_SET_LOCK) but isn't really put to sleep. > > > > 1. Why isn't it put to sleep - why can't it be treated the same? > 2. The eventual question I am trying to answer is the difference > between setrunnable() and setrunqueue() - this one simply finds a slot > in the ksegrp and a runq to add the KSE/td. But setrunnable() also > checks to see if the process is in memory (PS_INMEM) before calling > sched_wakeup which eventually calls setrunqueue()? Why doesn't > setrunqueue have to worry about the possibility that the process may > have been swapped out while it was waiting to become runnable? I just forgot to answer this: on 6.x serie (note that setrunqueue() shouldn't be available on 7.x and above), setrunqueue() is just used as backend for setrunnable(). Usually, setrunqueue() was used in places where the state of the thread was alredy assumed and no further check were needed. Thanks, Attilio -- Peace can only be achieved by understanding - A. Einstein