From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,9d303864ae4c70ad X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2004-04-16 15:15:46 PST Path: archiver1.google.com!postnews1.google.com!not-for-mail From: wojtek@power.com.pl (Wojtek Narczynski) Newsgroups: comp.lang.ada Subject: Re: Reprise: 'in out' parameters for functions Date: 16 Apr 2004 15:15:46 -0700 Organization: http://groups.google.com Message-ID: <5ad0dd8a.0404161415.220cce54@posting.google.com> References: <5ad0dd8a.0404090512.15af2908@posting.google.com> <5ad0dd8a.0404091828.6e79bb4e@posting.google.com> <8Oadneu6eY9pweDdRVn-hA@comcast.com> <5ad0dd8a.0404151752.4f598e1a@posting.google.com> <5ad0dd8a.0404160338.5a1c9116@posting.google.com> <1080a21p0nn482f@corp.supernews.com> NNTP-Posting-Host: 83.27.43.192 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit X-Trace: posting.google.com 1082153746 21577 127.0.0.1 (16 Apr 2004 22:15:46 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Fri, 16 Apr 2004 22:15:46 +0000 (UTC) Xref: archiver1.google.com comp.lang.ada:7229 Date: 2004-04-16T15:15:46-07:00 List-Id: Randy, > That's because it would be hard to avoid deadlock in such data structures. Yes, it is hard to avoid deadlocks. > The usual way of avoiding deadlock is the use the onion-skin model of > locking. With acyclic strucutres you do "crabbing" to avoid deadlocks. > To see the problem, consider a tree struction. You'd have to lock many nodes > if an insertion caused a rebalancing. If a second task tried to do a nearby > insertion at the same time, it also could lock a number nodes. It would be > quite likely for the second task to lock the nodes that it is going to > insert into, then the first task try to lock the same nodes to do a > rebalancing. So it would have to wait. Then the second task would discover > that it, too needs to do a rebalancing - but it can't, because the first > task already has locked some of the nodes that it needs to change for the > rebalancing. Classic deadlock. To avoid this situation, you have to lock the > whole data structure. This is not easy but solveable. For example ADABAS (and forks) relational database is organized as one large B* tree. It can be edited concurrently, it rebalances, and does not deadlock. One more example: Java heap, millions of objects, 64 CPUs, thousands of threads. Would you like to have one lock for the whole data strucutre? Regards, Wojtek