From owner-freebsd-current@FreeBSD.ORG Wed Feb 4 18:30:00 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 E41C516A4CE for ; Wed, 4 Feb 2004 18:30:00 -0800 (PST) Received: from web60607.mail.yahoo.com (web60607.mail.yahoo.com [216.109.118.245]) by mx1.FreeBSD.org (Postfix) with SMTP id E721043D45 for ; Wed, 4 Feb 2004 18:29:59 -0800 (PST) (envelope-from oldpopsong@yahoo.com) Message-ID: <20040205022959.94712.qmail@web60607.mail.yahoo.com> Received: from [218.244.38.34] by web60607.mail.yahoo.com via HTTP; Wed, 04 Feb 2004 18:29:59 PST Date: Wed, 4 Feb 2004 18:29:59 -0800 (PST) From: =?gb2312?q?popsong=20old?= To: freebsd-current@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=gb2312 Content-Transfer-Encoding: 8bit X-Mailman-Approved-At: Thu, 05 Feb 2004 05:14:12 -0800 Subject: 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: Thu, 05 Feb 2004 02:30:01 -0000 Hi, The test code below will result witness's warning of "lock order reversal": /* lock A then B */ mtx_lock(&A_mtx); mtx_lock(&B_mtx); mtx_unlock(&B_mtx); mtx_unlock(&A_mtx); /* lock B then C */ mtx_lock(&B_mtx); mtx_lock(&C_mtx); mtx_unlock(&C_mtx); mtx_unlock(&B_mtx); /* lock C then A, witness will complaint! */ mtx_lock(&C_mtx); mtx_lock(&A_mtx); mtx_unlock(&A_mtx); mtx_unlock(&C_mtx); But the code seems healthy and will not cause dead locking. So I guess that the lock order relationship should not be transferrable. Or am I missing something? song _________________________________________________________ Do You Yahoo!? 完全免费的雅虎电邮,马上注册获赠额外60兆网络存储空间 http://cn.rd.yahoo.com/mail_cn/tag/?http://cn.mail.yahoo.com