From owner-freebsd-hackers@FreeBSD.ORG Mon Oct 24 22:51:30 2011 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 023BB1065701 for ; Mon, 24 Oct 2011 22:51:30 +0000 (UTC) (envelope-from asmrookie@gmail.com) Received: from mail-wy0-f182.google.com (mail-wy0-f182.google.com [74.125.82.182]) by mx1.freebsd.org (Postfix) with ESMTP id 81E7E8FC17 for ; Mon, 24 Oct 2011 22:51:29 +0000 (UTC) Received: by wyi40 with SMTP id 40so8689298wyi.13 for ; Mon, 24 Oct 2011 15:51:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=mime-version:sender:in-reply-to:references:date :x-google-sender-auth:message-id:subject:from:to:cc:content-type; bh=YUvA925Q3aHMGmews2Sg2s7enMX64c8+sIsaAuSV1d0=; b=lGVhM2J1B4tDsk7de00hRF/LF55tsOHFhLFHNeollIIPLIzIupbhf3tWVzsLNzTPTR VH40b7JA5YhFxvE8HXT++kC5+apLy5TqPR9WrBqFIreYY6JVDhCVKbCbBWG0WAGyj3GZ OVCaD8r/JTWQzr4Z0PkLqsJT8lTWv+UG5Oi74= MIME-Version: 1.0 Received: by 10.216.136.168 with SMTP id w40mr3881486wei.27.1319494972465; Mon, 24 Oct 2011 15:22:52 -0700 (PDT) Sender: asmrookie@gmail.com Received: by 10.216.182.3 with HTTP; Mon, 24 Oct 2011 15:22:52 -0700 (PDT) In-Reply-To: References: Date: Tue, 25 Oct 2011 00:22:52 +0200 X-Google-Sender-Auth: pmwOgvbb9ZmpY4axeUfGRtuwH1Y Message-ID: From: Attilio Rao To: Haozhong Zhang Content-Type: text/plain; charset=UTF-8 Cc: freebsd-hackers@freebsd.org Subject: Re: question about the exchanges of td->td_lock and mtx in sched_switch() of sched_ule 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, 24 Oct 2011 22:51:30 -0000 2011/10/13 Haozhong Zhang : > Hi, > > I'm recently reading the code of sched_ule in freebsd 8.2.0 and have two > questions. > > 1. sched_switch() (in sched_ule.c) invokes cpu_switch() (at line 1852) and > thread_unblock_switch() (at line 1867). These two functions exchange > td->td_lock and mtx. What are the purposes of these exchanges? > > 2. Can the exchange in cpu_switch() (in amd64/amd64/cpu_switch.S, at line > 134) be done before calling cpu_switch()? I mean, does this reorder of > exchange and other operations in cpu_switch() cause side-effects to other > code? This thread should have the details you need: http://lists.freebsd.org/pipermail/svn-src-all/2010-January/019345.html Attilio -- Peace can only be achieved by understanding - A. Einstein