From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on ip-172-31-65-14.ec2.internal X-Spam-Level: X-Spam-Status: No, score=-3.2 required=3.0 tests=BAYES_00,NICE_REPLY_A, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 Path: eternal-september.org!news.eternal-september.org!news.szaf.org!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail From: Niklas Holsti Newsgroups: comp.lang.ada Subject: Re: Is a Boolean type inherently atomic ? Date: Fri, 12 May 2023 20:38:29 +0300 Organization: Tidorum Ltd Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Trace: individual.net v2NygZ34RZda/WCdk2dpKw0EYf9gUVKGnPsvVsMUgmSMZHitdI Cancel-Lock: sha1:IncuqcJtbsVaJCKIfFcTX8XA5Wk= User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.14; rv:102.0) Gecko/20100101 Thunderbird/102.6.1 Content-Language: en-US In-Reply-To: Xref: news.eternal-september.org comp.lang.ada:65213 List-Id: On 2023-05-12 15:17, Rod Kay wrote: >    Surely only the least significant bit of the least significant byte > is relevant and so the value cannot be garbled by one task writing and > another reading at the same time ? That seems very likely indeed, unless (as others have commented) the representation has been specified to use more bits. However, the Ada RM states in C.6(8/3) that "every atomic type or object is also defined to be volatile", and of course Boolean variables are not considered volatile unless they are specified to be Atomic or Volatile. So a Boolean type is not inherently atomic in the Ada RM sense of "atomic". And of course if you use a shared variable to communicate data between tasks, that variable should be marked as Volatile, and there should also be some Atomic accesses to ensure that actions are "sequential", so marking the variable as Atomic is best.