From owner-freebsd-hackers@FreeBSD.ORG Thu Oct 13 12:58:56 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 9E0AF1065707 for ; Thu, 13 Oct 2011 12:58:56 +0000 (UTC) (envelope-from snowzh8512@gmail.com) Received: from mail-gx0-f182.google.com (mail-gx0-f182.google.com [209.85.161.182]) by mx1.freebsd.org (Postfix) with ESMTP id 5FF398FC0A for ; Thu, 13 Oct 2011 12:58:56 +0000 (UTC) Received: by ggeq3 with SMTP id q3so2324374gge.13 for ; Thu, 13 Oct 2011 05:58:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=mime-version:from:date:message-id:subject:to:content-type; bh=OXZbNwHnNF4/hclKtZG+cihyQTL94hCpuwOl7pso8H8=; b=LXfej3e+HA05/az67TaTk04CeTz9oMNWq1S5er1FWDLt7NPDHnWMYTXWtRjYQh4qHY gi5H+MTKhnQgJRR1NCCUn+Epm87qjtVzFan4i0HHwP6GswNFk7Y6k1HXnEbloqe0QK4j jd64W4jTMq9ui6aeMeaBdy2cTbndwuPYfeW64= Received: by 10.100.253.3 with SMTP id a3mr647088ani.116.1318509349181; Thu, 13 Oct 2011 05:35:49 -0700 (PDT) MIME-Version: 1.0 Received: by 10.100.228.20 with HTTP; Thu, 13 Oct 2011 05:35:09 -0700 (PDT) From: Haozhong Zhang Date: Thu, 13 Oct 2011 08:35:09 -0400 Message-ID: To: freebsd-hackers@freebsd.org Content-Type: text/plain; charset=UTF-8 X-Content-Filtered-By: Mailman/MimeDel 2.1.5 Subject: 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: Thu, 13 Oct 2011 12:58:56 -0000 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? Thank you! - Haozhong Zhang