From owner-freebsd-current@FreeBSD.ORG Thu Feb 5 18:06:18 2004 Return-Path: Delivered-To: freebsd-current@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id E241416A4CE for ; Thu, 5 Feb 2004 18:06:18 -0800 (PST) Received: from web60606.mail.yahoo.com (web60606.mail.yahoo.com [216.109.118.244]) by mx1.FreeBSD.org (Postfix) with SMTP id E3C4643D54 for ; Thu, 5 Feb 2004 18:06:16 -0800 (PST) (envelope-from oldpopsong@yahoo.com) Message-ID: <20040206020616.12702.qmail@web60606.mail.yahoo.com> Received: from [218.244.38.34] by web60606.mail.yahoo.com via HTTP; Fri, 06 Feb 2004 10:06:16 CST Date: Fri, 6 Feb 2004 10:06:16 +0800 (CST) From: =?gb2312?q?popsong=20old?= To: John Baldwin In-Reply-To: <200402051418.54247.jhb@FreeBSD.org> MIME-Version: 1.0 Content-Type: text/plain; charset=gb2312 Content-Transfer-Encoding: 8bit X-Mailman-Approved-At: Fri, 06 Feb 2004 05:12:59 -0800 cc: freebsd-current@freebsd.org Subject: Re: three locks and lock order reversal? X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Discussions about the use of FreeBSD-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 06 Feb 2004 02:06:19 -0000 > If one thread does A then B, another thread does B then C, and a third thread > does C then A you can deadlock if each thread gets the first lock and blocks > on the second lock. Thread 1 wants B and holds A, thread 2 holds B and wants > C, and thread 3 wants A and holds C. Thread 3 will not giveup C until it > gets A. Thread 1 holds A and won't give it up until it gets B. Thread 2 > holds B and won't give it up until it gets C which is held by thread 3. > Hence, deadlock. > > -- > John Baldwin <>< http://www.FreeBSD.org/~jhb/ > "Power Users Use the Power to Serve" = http://www.FreeBSD.org > Thank you for the explanation! I only thought of two threads. So this bring me another question: if the machine only have 2 CPUs, does it mean that this kind of LOR is safe, provided there is no other sleep lock between A and B, B and C, C and A? song _________________________________________________________ Do You Yahoo!? 完全免费的雅虎电邮,马上注册获赠额外60兆网络存储空间 http://cn.rd.yahoo.com/mail_cn/tag/?http://cn.mail.yahoo.com