Thanks for review. On Wed, 29 May 2019 at 19:44, Boqun Feng <boqun.f...@gmail.com> wrote: > > > @@ -424,7 +424,7 @@ static void rwsem_ABBA2(void) > > ML(Y1); > > RSL(X1); > > RSU(X1); > > - MU(Y1); // should fail > > + MU(Y1); // should NOT fail > > I'm afraid you get this wrong ;-) reader of rwsem is non-recursive if I > understand correctly, so case like: > > Task 0 Task 1 > > down_read(A); > mutex_lock(B); > > down_read(A); > mutex_lock(B); > > can be a deadlock, if we consider a third independent task: > > Task 0 Task 1 Task 2 > > down_read(A); > mutex_lock(B); > down_write(A); > down_read(A); > mutex_lock(B); > > in this case, Task 1 can not get it's lock for A, therefore, deadlock.
Well, yes. This situation is damn counterintuitive and looks suboptimal, but I guess I can understand why this is done so. It is a shame read locks are not 100% concurrent. I wish I were bright enough to have figured this out on my own. Ok, now this perhaps can be easily remedied. it is merely a matter that finally I can set straight the lock exclusiveness table, and then from there the only change seems to be now only recursive-read locks are no deadlock. Thanks, Yuyang