Re: how to cast away 'volatile'?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Ian Lance Taylor wrote:
> That means that the only correct way to share a memory buffer between
> threads is to use a mutex, and it means that the mutex code can not be
> written in standard conformant C.  The mutex code must use asm
> statements to insert memory barriers as required (on the x86 a lock
> prefix serves as a memory barrier (except that some specific x86
> processors have bugs, but I digress...)).

This comment makes me curious, since I see (and work on) plenty of code
that shares data structures between threads using only a mutex for
protection and no memory barrier instructions of any kind. This code is
using standard POSIX threading constructs and seems to work fine on
multi-CPU and multi-core systems, both x86 and other flavors.

Are you referring to a specific sort of memory sharing between threads
here, or are you saying that you think that _all_ objects shared between
threads need to be protected in this way?

[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux