Re: race on multi-processor solaris

From: Gavin Maltby (G_a_v_i_n.M_a_l_t_b_y_at_sun.com)
Date: 11/14/03


Date: Fri, 14 Nov 2003 16:37:28 +0000

Joe Seigh wrote:

>>Well, there's a bit of "atomic reference counting" going on in
>>Solaris.
>
>
> Really? Atomic as opposed to merely thread-safe? Detlefs seems to
> think it's impossible without DCAS. Boost shared_ptr is thread-safe,
> not atomic. Java ptrs are atomic. You get valid values no matter how
> you use them. In C++ that means no invalid values which could cause
> a segfault.

I'm not certain we're singing from the same glossary sheet here.
I'd call an "atomic reference count" a successful inc/dec made to a counter
using CAS, along these lines:

        do {
                old = *addr;
                new = old + 1;
        while (cas(addr, old, new) fails);

Nothing to do with threads or thread safety there.

Gavin



Relevant Pages

  • Re: Class and Multi-thread safety
    ... Putting lockdoesn't make it thread-safe. ... Thread safety is not a simple matter - you need to carefully consider ... holding a lock - if you're not careful, ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: The fread() that could.
    ... Well, if stream i/o is not thread-safe, the odds are pretty good that it ... doesn't matter whether you're talking about two threads accessing one file, ... Don't use synch objects for this, convert it all to something thread-safe ... is no point in blocking one thread from reading just because another thread ...
    (microsoft.public.win32.programmer.kernel)