T.R | Title | User | Personal Name | Date | Lines |
---|
1450.1 | Independent Quadwords are always OK | WIBBIN::NOYCE | Pulling weeds, pickin' stones | Thu Dec 12 1996 17:00 | 29 |
1450.2 | | DCEIDL::BUTENHOF | Dave Butenhof, DECthreads | Fri Dec 13 1996 06:57 | 24 |
1450.3 | | APACHE::CHAMBERS | | Fri Dec 13 1996 08:53 | 18 |
1450.4 | MB is a machine instruction... | VIRKE::GULLNAS | Olof Gulln�s, DTN 876-7997 | Fri Dec 13 1996 12:40 | 4 |
1450.5 | And, it's not a no-op! | WTFN::SCALES | Despair is appropriate and inevitable. | Fri Dec 13 1996 15:43 | 5 |
1450.6 | | DCEIDL::BUTENHOF | Dave Butenhof, DECthreads | Mon Dec 16 1996 08:07 | 30 |
1450.7 | So why isn't MB in the man pages? | APACHE::CHAMBERS | | Mon Dec 16 1996 16:23 | 53 |
1450.8 | | DCEIDL::BUTENHOF | Dave Butenhof, DECthreads | Tue Dec 17 1996 06:29 | 102 |
1450.9 | | APACHE::CHAMBERS | | Tue Dec 17 1996 09:34 | 43 |
1450.10 | | SMURF::DENHAM | USG | Tue Dec 17 1996 10:17 | 6 |
1450.11 | | DCEIDL::BUTENHOF | Dave Butenhof, DECthreads | Tue Dec 17 1996 10:19 | 51 |
1450.12 | | APACHE::CHAMBERS | | Tue Dec 17 1996 10:29 | 32 |
1450.13 | | DCEIDL::BUTENHOF | Dave Butenhof, DECthreads | Tue Dec 17 1996 10:41 | 32 |
1450.14 | | APACHE::CHAMBERS | | Tue Dec 17 1996 10:49 | 39 |
1450.15 | | DCEIDL::BUTENHOF | Dave Butenhof, DECthreads | Tue Dec 17 1996 12:14 | 23 |
1450.16 | | COL01::LINNARTZ | | Thu Dec 19 1996 14:39 | 12 |
1450.17 | | CSC32::D_DERAMO | Dan D'Eramo, Customer Support Center | Thu Dec 19 1996 19:22 | 125 |
1450.18 | Threads and optimization | DCEIDL::BUTENHOF | Dave Butenhof, DECthreads | Fri Dec 20 1996 06:22 | 46 |
1450.19 | | COL01::LINNARTZ | | Fri Dec 20 1996 09:22 | 15 |
1450.20 | I'm not sure you need to worry, Dave | WIBBIN::NOYCE | Pulling weeds, pickin' stones | Fri Dec 20 1996 09:49 | 24 |
1450.21 | | DCEIDL::BUTENHOF | Dave Butenhof, DECthreads | Fri Dec 20 1996 13:26 | 11 |
1450.22 | | CSC32::D_DERAMO | Dan D'Eramo, Customer Support Center | Fri Dec 20 1996 13:50 | 45 |
1450.23 | Questions regarding implementations volatile is not needed | VAXCPU::michaud | Jeff Michaud - ObjectBroker | Sun Mar 23 1997 21:45 | 21 |
| > BUT, you should never need to use "volatile" for any variable protected by a
> mutex. And, if you do, then the compiler did something bad, or the thread
> library failed to do something to prevent the compiler from doing something
> bad -- depending upon your point of view. Any implementation of POSIX threads
> that requires you to use "volatile" on shared data (protected by a mutex) is
> simply broken.
I had relayed the info in .18 to the rest of my project and
regarding the above, the following questions came up:
Is this only true with "POSIX threads", or is this also true with
DCE threads? How about Solaris threads?
And is this only true if the calling language is C, or does it
also apply to C++?
I personally had never run into a problem in *not* using
volatile on data protected by a mutex, using DCE threads
since back to the 1st release of DEC OSF/1, and ULTRIX
before that (when it was still called POSIX draft or CMA).
But maybe I've only been lucky?
|
1450.24 | | DCETHD::BUTENHOF | Dave Butenhof, DECthreads | Mon Mar 24 1997 05:59 | 25 |
| The POSIX standard is specifically written so that an implementation that
required "volatile" for shared variables would be nonconforming. ("Illegal".)
The POSIX standard applies only to the POSIX 1003.1c-1995 thread interface,
and only to the C language.
So therefore, there's no "standard" requiring rational behavior from DCE
threads, or from UI ("Solaris") threads, or for the C++ language.
On the other hand, there are basically two categories of program behavior
that affect this -- the compiler's treatment of temporary variables, and the
hardware's treatment of cache memory coherence across hardware
synchronization. I doubt that it's practical to create SMP hardware that
wouldn't guarantee memory coherence across processors based entirely on the
synchronization instructions that would be used to implement a mutex. It
would be possible to build a "higher level" language than C that required
fewer and less conservative "sequence points" in variables, but I don't think
C++ is restrictive enough to allow it.
And, most importantly, any language that doesn't allow you to use threads
without something as heavy-weight as "volatile" simply isn't compatible with
threads -- and that would make it essentially useless for real programs,
because volatile is too expensive.
/dave
|
1450.25 | Don't scrimp. | WTFN::SCALES | Despair is appropriate and inevitable. | Mon Mar 24 1997 08:58 | 28 |
| Without having reread the foregoing notes... (:-)
.23> Is this only true with "POSIX threads", or is this also true with DCE
.23> threads? How about Solaris threads?
With one exception, this is true for DCE threads. I expect it's the same for
Solaris threads, as well.
The exception is the case where the program is using different mutexes to
protect adjacent portions of memory which are smaller than the atomic access
size (e.g., bytes, on an EV4/EV5 Alpha).
.23> And is this only true if the calling language is C, or does it also
.23> apply to C++?
It should apply equally to basically any language (I think).
.23> I personally had never run into a problem in *not* using volatile on
.23> data protected by a mutex [...] maybe I've only been lucky?
I doubt it; more likely you don't try to "bit-bum", cramming fields into
bytes or booleans into bitfields. While these practices may save memory,
they usually cost in performance (and other access problems, like the above),
and memory is MUCH cheaper than performance or correctness... :-)
Webb
|