[Search for users] [Overall Top Noters] [List of all Conferences] [Download this site]

Conference clt::cma

Title:DECthreads Conference
Moderator:PTHRED::MARYSTEON
Created:Mon May 14 1990
Last Modified:Fri Jun 06 1997
Last Successful Update:Fri Jun 06 1997
Number of topics:1553
Total number of notes:9541

1450.0. "What's the "atomic memory chunk size"?" by APACHE::CHAMBERS () Thu Dec 12 1996 19:24

T.RTitleUserPersonal
Name
DateLines
1450.1Independent Quadwords are always OKWIBBIN::NOYCEPulling weeds, pickin' stonesThu Dec 12 1996 20:0029
1450.2DCEIDL::BUTENHOFDave Butenhof, DECthreadsFri Dec 13 1996 09:5724
1450.3APACHE::CHAMBERSFri Dec 13 1996 11:5318
1450.4MB is a machine instruction...VIRKE::GULLNASFri Dec 13 1996 15:404
1450.5And, it's not a no-op!WTFN::SCALESDespair is appropriate and inevitable.Fri Dec 13 1996 18:435
1450.6DCEIDL::BUTENHOFDave Butenhof, DECthreadsMon Dec 16 1996 11:0730
1450.7So why isn't MB in the man pages?APACHE::CHAMBERSMon Dec 16 1996 19:2353
1450.8DCEIDL::BUTENHOFDave Butenhof, DECthreadsTue Dec 17 1996 09:29102
1450.9APACHE::CHAMBERSTue Dec 17 1996 12:3443
1450.10SMURF::DENHAMUSGTue Dec 17 1996 13:176
1450.11DCEIDL::BUTENHOFDave Butenhof, DECthreadsTue Dec 17 1996 13:1951
1450.12APACHE::CHAMBERSTue Dec 17 1996 13:2932
1450.13DCEIDL::BUTENHOFDave Butenhof, DECthreadsTue Dec 17 1996 13:4132
1450.14APACHE::CHAMBERSTue Dec 17 1996 13:4939
1450.15DCEIDL::BUTENHOFDave Butenhof, DECthreadsTue Dec 17 1996 15:1423
1450.16COL01::LINNARTZThu Dec 19 1996 17:3912
1450.17CSC32::D_DERAMODan D'Eramo, Customer Support CenterThu Dec 19 1996 22:22125
1450.18Threads and optimizationDCEIDL::BUTENHOFDave Butenhof, DECthreadsFri Dec 20 1996 09:2246
1450.19COL01::LINNARTZFri Dec 20 1996 12:2215
1450.20I'm not sure you need to worry, DaveWIBBIN::NOYCEPulling weeds, pickin' stonesFri Dec 20 1996 12:4924
1450.21DCEIDL::BUTENHOFDave Butenhof, DECthreadsFri Dec 20 1996 16:2611
1450.22CSC32::D_DERAMODan D'Eramo, Customer Support CenterFri Dec 20 1996 16:5045
1450.23Questions regarding implementations volatile is not neededVAXCPU::michaudJeff Michaud - ObjectBrokerMon Mar 24 1997 00:4521
> 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.24DCETHD::BUTENHOFDave Butenhof, DECthreadsMon Mar 24 1997 08:5925
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.25Don't scrimp.WTFN::SCALESDespair is appropriate and inevitable.Mon Mar 24 1997 11:5828
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