Re: recursive spinlocks. Shoot.

From: Daniel Phillips (phillips@arcor.de)
Date: Wed May 21 2003 - 20:21:52 EST


On Monday 19 May 2003 13:37, Nikita Danilov wrote:
> There, however, are cases when recursive locking is needed. Take, for
> example, top-to-bottom insertion into balanced tree with per-node
> locking. Once modifications are done at the "leaf" level, parents should
> be locked and modified, but one cannot tell in advance whether different
> leaves have the same or different parents. Simplest (and, sometimes, the
> only) solution here is to lock parents of all children in turn, even if
> this may lock the same parent node several times---recursively.

Having locked the parent of one child you then check whether the parent of the
second child is in fact the same, in which case you already hold the lock and
must remember to unlock it only once, otherwise lock the second parent. Do
you see a hole in that?

Regards,

Daniel
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/



This archive was generated by hypermail 2b29 : Fri May 23 2003 - 22:00:47 EST