Messages in this thread | | | From | Daniel Phillips <> | Subject | Re: recursive spinlocks. Shoot. | Date | Thu, 22 May 2003 03:21:52 +0200 |
| |
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/
| |