• Re: Is a Boolean type inherently atomic ?

    From Jeffrey R.Carter@21:1/5 to Rod Kay on Fri May 12 14:53:24 2023
    On 2023-05-12 14: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 ?

    Boolean types with other representations using multiple bits are possible, so your assumption doesn't hold.

    --
    Jeff Carter
    "Many times we're given rhymes that are quite unsingable."
    Monty Python and the Holy Grail
    57

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Rod Kay@21:1/5 to All on Fri May 12 22:17:48 2023
    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 ?


    Regards.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From J-P. Rosen@21:1/5 to All on Fri May 12 18:56:54 2023
    Le 12/05/2023 à 14:53, Jeffrey R.Carter a écrit :
    On 2023-05-12 14: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 ?

    Boolean types with other representations using multiple bits are
    possible, so your assumption doesn't hold.

    True, especially considering the special exception for boolean types in
    13.4(8)

    Anyway, if you intend to access a variable from multiple tasks, it
    doesn't cost much to add an aspect Atomic to the declaration, at least
    to inform the reader!

    --
    J-P. Rosen
    Adalog
    2 rue du Docteur Lombard, 92441 Issy-les-Moulineaux CEDEX
    https://www.adalog.fr https://www.adacontrol.fr

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Niklas Holsti@21:1/5 to Rod Kay on Fri May 12 20:38:29 2023
    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.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From AdaMagica@21:1/5 to All on Fri May 12 11:02:15 2023
    AARM 3.5.3(1.a), 13.4(8.b, 10/5) has some information about boolean representations.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Rod Kay@21:1/5 to All on Sat May 13 10:28:39 2023
    Okay, thank you all for the information.


    Regards.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)