lkml.org 
[lkml]   [2003]   [May]   [21]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
SubjectRe: recursive spinlocks. Shoot.
Date
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/

\
 
 \ /
  Last update: 2005-03-22 13:35    [W:0.053 / U:0.940 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site