Thread-safety guarantees for basic ops



Hi,

When thinking about thread-safety I've been assuming that the
following are automatically thread-safe without the need for any
explicit locking by the programmer:

- Reading a reference value

- Writing a reference value

- Reading/writing built-in simple types sized 32 bits or less (Int32,
Boolean etc)

(I'm not talking about swaps or read-modify-write sequences; they
obviously need explicit handling.)

I'm slightly worried that I've never seen these assumptions explicitly
confirmed. It's implied in some places - e.g. there's an
Interlocked.Read(ref long) but no Interlocked.Read(ref int) - but I
was hoping someone could point me to an official guarantee in the
docs.

I've also been assuming that static constructors are automatically
thread-safe (i.e. don't need to be reentrant), but I'm more confident
about that one.

cheers
Mike
.



Relevant Pages

  • Re: Thread-safety guarantees for basic ops
    ... following are automatically thread-safe without the need for any ... explicit locking by the programmer: ... This depends on the size of the Reference. ... Reading Word-Sizes ...
    (microsoft.public.dotnet.framework.clr)
  • Re: Thread-safety guarantees for basic ops
    ... explicit locking by the programmer: ... This depends on the size of the Reference. ... Reading Word-Sizes ... That depends on what you mean by "thread-safe". ...
    (microsoft.public.dotnet.framework.clr)
  • Re: Abstract public member variales?
    ... every object that has ever come out of the factory persistent, ... Usually that is trivial because to pass the reference the message sender needs the reference in hand and it shouldn't have access to it after the object is deleted. ... GC causes more problems than it is worth and to be safe one should always invoke an explicit 'delete' method when an object's life cycle is done regardless of whether the language provides GC or not. ... since an object that is no longer useful can likely be safely deleted from the set of domain objects (ignoring persistence). ...
    (comp.object)
  • Re: Question on LSP
    ... not have to be explicit attributes, ... Since objects in memory usually don't move, the language can largely hide the identity mapping. ... My issue here is that whatever semantic meta model the language uses, there must be some way for the developer to unambiguously express the OOA/D is-a semantics for some problem space entity. ... Note that the language allows us to use a name like 'T' on the reference as a mnemonic so that the developer can keep track of what is happening with the indirection. ...
    (comp.object)
  • Re: Odd (undocumented?) behavior of RAM file within a loop
    ... use strict; use warnings; ... close statement (on AS Perl 5.10 on Win32). ... Note that the explicit close results in the reference to the same ...
    (comp.lang.perl.misc)