Re: Thread-safety guarantees for basic ops



<"Günter Prossliner" <g.prossliner/gmx/at>> wrote:
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

This depends on the size of the Reference. Reading Word-Sizes (Int32 on x32)
are thread-safe, but above not (Int64 on x32). Obviously for 64 bit
Platforms, reading Int64 is also threadsafe.

That depends on what you mean by "thread-safe". They're atomic, but
unless you take *some* sort of action, there'll be no guarantee you get
the latest value.

Personally, I don't count "I'll read a value which was definitely valid
at some point, but might be an hour out of date" as thread-safe :)

--
Jon Skeet - <skeet@xxxxxxxxx>
http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
World class .NET training in the UK: http://iterativetraining.co.uk
.



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)
  • Thread-safety guarantees for basic ops
    ... explicit locking by the programmer: ... Reading a reference value ... thread-safe, ...
    (microsoft.public.dotnet.framework.clr)
  • Re: send(), sendmsg(), sendto() not thread-safe
    ... whether these functions are supposed to be thread-safe, my reading of the ... POSIX/SUSv3 specification tells me that they should be. ... BSD defines BSD socket semantics here not some wording in ...
    (Linux-Kernel)
  • RE: send(), sendmsg(), sendto() not thread-safe
    ... whether these functions are supposed to be thread-safe, my reading of the ... POSIX/SUSv3 specification tells me that they should be. ... Please read the FAQ at http://www.tux.org/lkml/ ...
    (Linux-Kernel)
  • Re: DTS Datapump Column Order Unstable
    ... According to the SQL Online Help I have been reading. ... For this to work I need to reference the Destination fields in a specific ... wizard issue and occurs anytime I reenter the wizard dialog ... when the Source collection order is correct, ...
    (microsoft.public.sqlserver.dts)

Loading