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=-0.3 required=5.0 tests=BAYES_00, REPLYTO_WITHOUT_TO_CC autolearn=no autolearn_force=no version=3.4.4 Path: eternal-september.org!reader01.eternal-september.org!reader02.eternal-september.org!news.eternal-september.org!news.eternal-september.org!news.eternal-september.org!feeder.eternal-september.org!aioe.org!.POSTED!not-for-mail From: "Dmitry A. Kazakov" Newsgroups: comp.lang.ada Subject: Re: Safety of unprotected concurrent operations on constant objects Date: Tue, 13 May 2014 21:15:23 +0200 Organization: cbb software GmbH Message-ID: References: <83ha6vuynrzs.1jk08faxb8mnl.dlg@40tude.net> <1jebi7cf92ak4.1trmstj8qi3wm.dlg@40tude.net> <1i6pyg077xlrv.vnwotzzgb0ut$.dlg@40tude.net> <10pk27v48vhcb$.1qkf6roq2yzjn$.dlg@40tude.net> <1qq0ryc8c4l2m.1driqwwiwwl02.dlg@40tude.net> <%vhcv.255737$s87.168969@fx11.iad> <30rcv.17381$Nf2.13630@fx01.iad> Reply-To: mailbox@dmitry-kazakov.de NNTP-Posting-Host: AuYlnUSfTZrfhAkRjyySpQ.user.speranza.aioe.org Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Complaints-To: abuse@aioe.org User-Agent: 40tude_Dialog/2.0.15.1 X-Notice: Filtered by postfilter v. 0.8.2 Xref: news.eternal-september.org comp.lang.ada:19810 Date: 2014-05-13T21:15:23+02:00 List-Id: On Tue, 13 May 2014 17:46:58 +0100, Simon Wright wrote: > Brad Moore writes: > >> That may be why Ada has PO's in the standard, but does not provide any >> mutex libraries like the one you suggest; They are too error >> prone. I'd be surprised if mutexes and scope locks like the one in >> your example wouldn't have been considered for inclusion in the >> standard at some point during the history of Ada. Ada does provide >> the building blocks that programmers can create such abstractions >> however, which programmers are then free to use as they wish. > > I've several times seen Randy recommend use of the Containers as a way > of avoiding problems with memory allocation/deallocation, and I'd have > thought simple mutexes/locks would be just as much candidates to support > the general user. > > Are they error-prone? If Joe Programmer reinvents locking, what's the > chance that there's something wrong with it? Usually to mutex' seize and release there are other procedures and entries added, e.g. when mutex is used with a container like a queue. So it is not much advantage having them in the standard library. Then there are mutex variations like reentrant mutexes, read-write mutexes, arrays of mutexes, ordered mutexes (in order to prevent deadlock), global (system-wide) named mutexes etc. This is why I am sceptical that mutexes must be in the standard library. Much more useful IMO would be atomic operations like atomic increment, compare and swap, and a requirement to support pragma Atomic for every scalar type. -- Regards, Dmitry A. Kazakov http://www.dmitry-kazakov.de