Loading ...
Sorry, an error occurred while loading the content.

Re: Asserting Attachment

Expand Messages
  • Gordon Jones
    ... Errm. I dont see how this could fail, at least not on any modern 32 and 64 bit hardware architectures? Even if not protected by a mutex, and the operating
    Message 1 of 8 , Sep 1, 2005
    • 0 Attachment
      > > create foo
      > > check foo /= Void end
      > >
      > > This assertion also can never fail, right?
      >
      > This could fail in a multithreaded environment if `foo' is an attribute.

      Errm. I dont see how this could fail, at least not on any modern 32
      and 64 bit hardware architectures? Even if not protected by a mutex,
      and the operating system scheduler switched threads at the must
      unfortunate time between the 2 lines, the write of the address of foo
      is atomic, each thread would get the value created by one of the
      threads - Agreed it might not be the one just created in its own
      thread, but it would not be void. Or have I missed something?
    • Peter Gummer
      ... It might be void if the other thread did this: foo := Void So there is a small chance that the assertion would fail. Nonetheless, the check instruction
      Message 2 of 8 , Sep 1, 2005
      • 0 Attachment
        Gordon Jones wrote:

        >>> create foo
        >>> check foo /= Void end
        >>
        >> This could fail in a multithreaded environment if `foo' is an
        >> attribute.
        >
        > Agreed it might not be the one just created in its own
        > thread, but it would not be void.

        It might be void if the other thread did this:

        foo := Void

        So there is a small chance that the assertion would fail.
        Nonetheless, the 'check' instruction still seems redundant to me,
        because it doesn't guarantee anything useful: immediately after the
        assertion succeeds, some other thread might jump in and change 'foo',
        causing a crash on a subsequent line of code.

        I don't see any value in the assertion, even in a multithreaded
        system with 'foo' as an attribute.

        - Peter Gummer
      • Emmanuel Stapf [ES]
        ... My understanding is that because of processor caches on a multiprocessor machinie, it is possible to have this effect of getting Void or a different value
        Message 3 of 8 , Sep 1, 2005
        • 0 Attachment
          > would get the value created by one of the threads - Agreed it
          > might not be the one just created in its own thread, but it
          > would not be void. Or have I missed something?

          My understanding is that because of processor caches on a multiprocessor machinie,
          it is possible to have this effect of getting Void or a different value for the
          attribute if it is not protected.

          Regards,
          Manu
        • Gordon Jones
          ... multiprocessor machinie, ... value for the ... It is my understanding that all SMP architectures do offer guarantees about memory consistency between
          Message 4 of 8 , Sep 2, 2005
          • 0 Attachment
            > > would get the value created by one of the threads - Agreed it
            > > might not be the one just created in its own thread, but it
            > > would not be void. Or have I missed something?
            >
            > My understanding is that because of processor caches on a
            multiprocessor machinie,
            > it is possible to have this effect of getting Void or a different
            value for the
            > attribute if it is not protected.

            It is my understanding that all SMP architectures do offer guarantees
            about memory consistency between processors, even when they are using
            cpu intimate memory caches. The caches use techniques like bus
            snooping to see what addresses are being used by other caches.

            I also believe that some NUMA architectures also offer guarantees
            (cc-NUMA).

            I was trying to find references to back up this assertion, but I cant
            find a simple statement, only very complex descriptions about how its
            done. If I find one, I reply again.

            Regards Gordon
          Your message has been successfully submitted and would be delivered to recipients shortly.