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,FREEMAIL_FROM autolearn=ham autolearn_force=no version=3.4.4 X-Google-Thread: 103376,3a3dffa82925efee X-Google-Attributes: gid103376,public X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!news1.google.com!news.glorb.com!border1.nntp.dca.giganews.com!nntp.giganews.com!local1.nntp.dca.giganews.com!nntp.comcast.com!news.comcast.com.POSTED!not-for-mail NNTP-Posting-Date: Sun, 27 Jun 2004 19:51:19 -0500 Date: Sun, 27 Jun 2004 20:51:19 -0400 From: "Robert I. Eachus" User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.4) Gecko/20030624 Netscape/7.1 (ax) X-Accept-Language: en-us, en MIME-Version: 1.0 Newsgroups: comp.lang.ada Subject: Re: Advantages References: <2k86nbF18idtrU1@uni-berlin.de> In-Reply-To: <2k86nbF18idtrU1@uni-berlin.de> Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit Message-ID: NNTP-Posting-Host: 24.147.90.114 X-Trace: sv3-tWDSwwgMm+v/vXKVX353+kjP5mwAZ636p/HA9tytxJMQqNRk+LghK1AFAV/ZSfSEgziGIlPY2UmEAq0!TPGEFPAbieoaAY6U+lHeiRX0dDqdk1iUH7sPSuH5xjYcJe5mgmA9gpmqTJNG3A== X-Complaints-To: abuse@comcast.net X-DMCA-Complaints-To: dmca@comcast.net X-Abuse-and-DMCA-Info: Please be sure to forward a copy of ALL headers X-Abuse-and-DMCA-Info: Otherwise we will be unable to process your complaint properly X-Postfilter: 1.1 Xref: g2news1.google.com comp.lang.ada:1958 Date: 2004-06-27T20:51:19-04:00 List-Id: Nick Roberts wrote: > "Andrew Carroll" wrote in message > news:mailman.165.1088318818.391.comp.lang.ada@ada-france.org... > >>... What features of Ada make it easier to detect pitfalls >>in parallel programming? What features of Ada help with >>debugging? > > > I don't wish to cross with Marin in answering this, but forgive me if I > throw my oar in a bit. > > Suppose I have two threads (another name for 'tasks') which both need to > read a variable (which is a struct (record)) from time to time, and one of > them also updates the variable from time to time. When an update is done, it > involves assigning values to several of the variable's members (components), > so the update is not 'atomic'. This means that there needs to be some kind > of synchronisation between the threads, to prevent one thread trying to read > the variable right in the middle of it being updated. Nick's example is a good one, but it misses a part of the flavor of why it is such a huge advantage. If you know you are going to have to protect some object, you declare it as a protected object (makes sense ;-) with a Get function and a Set procedure. As the design and software development process proceeds, you may have to change the management of R dozens of times. But all these changes are local to the protected object that implements R. If as often happens in a system design, you need to hold two or more locks at once, you need to prevent the possibility deadlock. (Or you should prevent the possibility of deadlock.) One way to do this is to show that there is an ordering of all of the semaphores such that no task holds a higher numbered semaphore when it acquires a lower numbered semaphore. In Ada, if all these semaphores are actually internal to protected objects, the only way to hold R while acquiring S is for the protected object for R to have a call which internally calls the protected object for S. This is not hard to write in Ada, but the implicit ordering of with clauses will make it impossible for you to have a call that gets S while holding R, another call that gets T while holding S, and a third call that gets R while holding T. For that matter any matter any calling sequence that violates the rule will mean that the compiler will reject the program. So you can design, build and maintain complex real-time systems with many threads of control in Ada, and not only will there be no deadlocks, you won't have to do lots of analysis to show that the software is deadlock free. (Yes, you can put two protected objects in the same scope and violate the implicit ordering. But now the only source of potential deadlocks is in that one unit--that I hope violates your software development plan in some way.) -- Robert I. Eachus "Reason and experience both forbid us to expect that national morality can prevail in exclusion of religious principles." -- George Washington