three locks and lock order reversal?

From: popsong old <oldpopsong_at_yahoo.com>
Date: Wed, 4 Feb 2004 18:29:59 -0800 (PST)
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
Received on Wed Feb 04 2004 - 17:30:00 UTC

This archive was generated by hypermail 2.4.0 : Wed May 19 2021 - 11:37:41 UTC