help / color / mirror / Atom feed
From: Niklas Holsti <niklas.holsti@tidorum.invalid>
Subject: Re: Is a Boolean type inherently atomic ?
Date: Fri, 12 May 2023 20:38:29 +0300	[thread overview]
Message-ID: <> (raw)
In-Reply-To: <u3lap0$1hvas$>

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.

  parent reply	other threads:[~2023-05-12 17:38 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-05-12 12:17 Is a Boolean type inherently atomic ? Rod Kay
2023-05-12 12:53 ` Jeffrey R.Carter
2023-05-12 16:56   ` J-P. Rosen
2023-05-12 17:38 ` Niklas Holsti [this message]
2023-05-12 18:02 ` AdaMagica
2023-05-13  0:28 ` Rod Kay
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox