From owner-freebsd-hackers@FreeBSD.ORG Sun Dec 18 03:19:57 2005 Return-Path: X-Original-To: freebsd-hackers@freebsd.org Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 44F7C16A41F for ; Sun, 18 Dec 2005 03:19:57 +0000 (GMT) (envelope-from guomingyan@gmail.com) Received: from xproxy.gmail.com (xproxy.gmail.com [66.249.82.199]) by mx1.FreeBSD.org (Postfix) with ESMTP id 253F143D55 for ; Sun, 18 Dec 2005 03:19:55 +0000 (GMT) (envelope-from guomingyan@gmail.com) Received: by xproxy.gmail.com with SMTP id t12so707227wxc for ; Sat, 17 Dec 2005 19:19:55 -0800 (PST) DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; h=received:message-id:date:from:to:subject:cc:in-reply-to:mime-version:content-type:references; b=ZCr47xDhD9ue1QQ0ZhhWJ0padBZXTsiQw3AuMaigB6In01z2mzVxPYPDBl9vQkqhE7Mdnzby8fUG1OSGBZoZl+H64GSb3XBTR5poRo1gxXIantZu1mbaCMZgjgYnLOlA9AdzKk8vcKym6xjNQY7oddbqq1DxVdBTvPXyk5dTpvU= Received: by 10.70.82.3 with SMTP id f3mr2926005wxb; Sat, 17 Dec 2005 19:19:55 -0800 (PST) Received: by 10.70.39.18 with HTTP; Sat, 17 Dec 2005 19:19:55 -0800 (PST) Message-ID: <1fa17f810512171919k4a16f68dh3ad0d5f294fb3f23@mail.gmail.com> Date: Sun, 18 Dec 2005 11:19:55 +0800 From: prime To: rookie@gufi.org In-Reply-To: <3bbf2fe10512171207n41c9308dm@mail.gmail.com> MIME-Version: 1.0 References: <1fa17f810512170027h58ccadbcq9f8d3187f35a2ddd@mail.gmail.com> <3bbf2fe10512171207n41c9308dm@mail.gmail.com> Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Content-Disposition: inline X-Content-Filtered-By: Mailman/MimeDel 2.1.5 Cc: freebsd-hackers@freebsd.org Subject: Re: Puzzled about turnstile's lock 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: Sun, 18 Dec 2005 03:19:57 -0000 On 12/18/05, rookie wrote: > > > Hi hackers, > > I want to understand the current implementation of > > turnstile,and meet some questions about its locks' logicality. > > > [snip] > > It's used to lock td_contested member of struct thread structure and all > issues linked to it (as you can see in the source tree). It seems used in= a > clean way. > > Attilio > > turnstile's ``ts_blocked" field is protected by both > > ``td_contested" lock and its turnstile_chain lock, but > > I think its turnstile_chain lock is enough,because we > > allways get the turnstile_chain lock before our manipulation > > on ``ts_blocked". > > If td_contested lock were needed ,reading ts_blocked is > > not protected by td_contested lock,in the kernel source, why? > > > > Thanks. > > -- > > Three passions, simple but overwhelmingly strong, have governed my life= : > > the longing for love, the search for knowledge, and unbearable pity for > > the suffering of mankind. > > ---------Bertrand Russell > > _______________________________________________ > > freebsd-hackers@freebsd.org mailing list > > http://lists.freebsd.org/mailman/listinfo/freebsd-hackers > > To unsubscribe, send any mail to " > > freebsd-hackers-unsubscribe@freebsd.org" > > > > > > -- > Peace can only be achieved by understanding - A. Einstein Thanks,I think I get it now.As mentioned in arch-handbook =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D You can protect a datum with multiple locks. Then for reading that data you simply need to have a read lock of one of the locks. However, to write to the data, you need to have a write lock of all of the locks =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D We also can read "ts_blocked" if only td_contested lock is held,but this way is not needed now. -- Three passions, simple but overwhelmingly strong, have governed my life: the longing for love, the search for knowledge, and unbearable pity for the suffering of mankind. ---------Bertrand Russell