Loose type checking in E
Marc Stiegler
marcs@skyhunter.com
Mon, 12 Oct 1998 12:41:25 -0700
>I feel stupid saying this, since you obviously have far more experience
>than I do; but I think that I have created a deadlock free, multi-threaded
>GUI library for Java.
>
>I fully agree with you that using many fine-grained locks is just too
>complicated (not to mention ugly and inefficient). In my library, I have
>used the tree protocol from database theory to create a sort of apartment
>based threading model. Algorithms which operate on the GUI are given an
>Object to lock on before accessing the GUI data structure. If the GUI is
>multithreaded, then this Object will represent the apartment for the
>shallowest node in the GUI tree that is used by the algorithm. All of the
>methods of the objects in my GUI tree structure have been defined such that
>they obey the tree protocol, locking on deeper nested apartments as
necessary.
>
>I have found that this works very well, and that it is quite simple to show
>that deadlock will not occur.
Your strategy sounds like a variant of the "resource hierarchy" system
developed by operating systems people decades ago. Back in the '60s, in
fact, CDC used such a resource hierarchy to prevent deadlocks in their
operating systems; as one of my first "toy" programs when I first played
with Java, I wrote a resource hierarchy management class that could
guarantee no deadlocks as long as you always talked with the singleton
object of the class before locking a resource.
Unfortunately, as you use this strategy with increasing vigor, the method
degrades the advantages of multiple threads--things start acting more and
more linearly. Even though CDC had such a hierarchy built into its opsys,
CDC did not use the hierarchy for all its opsys resources--some resources
needed to be accessed with such speed that to make the system efficient,
they left 'em out of the hierarchy. Deadlocks on these resources
consequently occurred every so often (maybe once a day), and the CDC
answer--which was absolutely reasonable in their context--was to say, hey,
let the sys admin guy break the deadlock manually when he sees that one has
occurred.
Strange but true stories of the antiquity of computing :-)
--marcs