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,26f34062c627f3d4,start X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2001-01-21 03:22:06 PST From: Florian Weimer Newsgroups: comp.lang.ada Subject: Concurrent access to packed arrays Date: 21 Jan 2001 11:59:06 +0100 Organization: Enyo's not your organization Message-ID: <87g0id8939.fsf@deneb.enyo.de> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Path: supernews.google.com!sn-xit-03!supernews.com!freenix!fr.clara.net!heighliner.fr.clara.net!news.tele.dk!134.222.94.5!npeer.kpnqwest.net!nmaster.kpnqwest.net!blackbush.xlink.net!rz.uni-karlsruhe.de!news.uni-ulm.de!news.belwue.de!LF.net!news.enyo.de!news1.enyo.de!not-for-mail Xref: supernews.google.com comp.lang.ada:4253 Date: 2001-01-21T11:59:06+01:00 List-Id: For simplicity, assume the array is of type String. Some machines (early Alphas?) do not offer load/store functions for individual octets, so the characters of a string might not be independently addressable. Now suppose we have a string object and a variable which indicates the last position in the string which has been written: The_String : String (1 .. Some_Maximum); Last_Written : Natural; pragma Atomic (Last_Written); Task A1, A2, ... make a copy of Last_Written and read data from The_String (1 .. Copy_Of_Last_Written). Task B continues to write to The_String (Last_Written + 1 .. Some_Maximum) and update Last_Written. This might result in concurrent read and write access to the same memory location, but I think this will work anyway because task B writes to the location without changing the part interpreted by the reading tasks. However, according to the Ada standard, this scenario results in erroneous execution. Now my question: Are there in fact platforms where this doesn't work? Shall I play safe and apply pragma Atomic_Components (and use an unpacked array instead of a packed one)?