Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.c > #23137

Re: Clarification on the applicability of compile-time optimizationo to a struct variable which encompasses a mixture of fields declared as volatile and non-volatile individually

From Uncle Steve <stevet810@gmail.com>
Newsgroups comp.lang.c
Subject Re: Clarification on the applicability of compile-time optimizationo to a struct variable which encompasses a mixture of fields declared as volatile and non-volatile individually
Date 2012-07-06 19:47 -0400
Organization A noiseless patient Spider
Message-ID <d87c7549c660812-506c2@gmail.com> (permalink)
References (5 earlier) <b85c6e84-07dc-4b1c-b94e-d36ea0af03fb@n33g2000vbi.googlegroups.com> <c365530590f39fd-5d0be@gmail.com> <2a01b1e1-8607-47b3-a40b-44466901c511@j9g2000vbk.googlegroups.com> <fd30057892b3a7b-9f30b@gmail.com> <362f5134-1a84-457c-8fec-b55e988b6d12@f30g2000vbz.googlegroups.com>

Show all headers | View raw


On Fri, Jul 06, 2012 at 08:33:45PM -0700, Joshua Maurice wrote:
> On Jul 6, 4:25 pm, Uncle Steve <stevet...@gmail.com> wrote:
> > On Fri, Jul 06, 2012 at 08:12:57PM -0700, Joshua Maurice wrote:
> > > On Jul 6, 3:54 pm, Uncle Steve <stevet...@gmail.com> wrote:
> > > > On Fri, Jul 06, 2012 at 07:39:56PM -0700, Joshua Maurice wrote:
> > > > > I will say it again: the C89 and C99 standards do not mean what you
> > > > > think. What the compiler writers and thread library writers understand
> > > > > volatile to mean is not what you understand volatile to mean, and at
> > > > > the end of the day what the compiler writers and thread library
> > > > > writers think is paramount. You may be able to get this to work for
> > > > > specific platforms with specific compilers. I suggest you ask in a
> > > > > location specific to such implementations for such platform specific
> > > > > hackery. However, do not look at the C standard for guidance on this.
> >
> > > > Um, what is it that compiler writers and thread library writers
> > > > understand volatile to mean?
> >
> > >http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2006/n2016.html
> >
> > > > > In the C11 parlance, what you're trying to write requires the "weak"
> > > > > atomics, such as relaxed, acquire, release, and consume memory
> > > > > operations. Attempting to write stuff like this without C11 support
> > > > > with the C11 primitives is a wholly platform specific affair, and
> > > > > neither C89 nor C90 can help you there. volatile specifically cannot
> > > > > help you (barring platform specific documentation to the contrary).
> >
> > > > You seem to be making too many assumptions about my code.
> >
> > > I think it's pretty clear from what you've written else-thread.
> >
> > > > > From else-thread:
> > > > > On Jul 6, 2:29 pm, Uncle Steve <stevet...@gmail.com> wrote:
> > > > > > On Sat, Jul 07, 2012 at 12:37:59PM +1200, Ian Collins wrote:
> > > > > > > Then use your platform's native threading primitives.
> >
> > > > > > Doing so would incur a performance penalty in comparison to my
> > > > > > synchronization primitives in some circumstances.
> >
> > > > > That's your problem. You have broken code. Your options are:
> > > > > 1- broken code (e.g. using volatile and asm memory barriers absent
> > > > > platform specific guarantees)
> > > > > 2- code that relies on platform specific guarantees (e.g. with using
> > > > > volatile and asm memory barriers)
> > > > > 3- "slow" code (e.g. with posix mutexes)
> > > > > 4- C11 code
> >
> > > > How do you know, a priori, that my code is broken?  Do I have to
> > > > change my passwords again?
> >
> > > How do I know it's broken? By your own admission, you're using
> > > volatile to try and affect inter-thread visibility (absent constructs
> > > that actually give inter-thread visibility). By your previous
> > > statements about using the C standard to derive useful threading
> > > semantics for volatile, I doubt you've looked at the compiler
> > > documentation and hardware documentation for your implementation. Thus
> > > you have broken code. (I don't think you are trying to nit on "it
> > > could be right by coincidence".)
> >
> > Well you know what?  You're going to have to wait until version 1.0
> > before you get to decide how wrong it is.
> 
> Let me share with you a story. I currently work for a company selling
> Enterprise software. The software is heavily intertwined with
> databases. We have a license for a large piece of code that does heavy
> duty sorting. We have a contract with the guys who wrote this sorting
> library for support and maintenance. One of our customers upgraded
> some of their hardware, ran some tests - or possibly worse ran actual
> usage - and noticed that one row out of a few billion was "missing".
> Our engine dropped it, somewhere. It should be in the output, but it
> wasn't. Of course, this is very bad for our company. This could cost
> millions of dollars in sales. So, we get the guys who wrote the
> sorting library, and immediately fly them out to us. We get them to
> work on the code. I was only tangentially related to this process. It
> took a week or so of work to find and fix the issue. What was the
> problem? The guys who wrote the sorting library used "volatile", and
> the customer just upgraded to some itanium processor or something. A
> quick fix/hack later, and our customer was back in business, our
> millions of dollars was secure, as was our company image and
> reputation.
> 
> Use volatile at your own risk. I don't plan on using your software if
> I can help it.

Well I wouldn't want you to use any software that you didn't want to
run.


Regards,

Uncle Steve

-- 
The moon has never been closer.

Back to comp.lang.c | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

Clarification on the applicability of compile-time optimization to a struct variable which encompasses a mixture of fields declared as volatile and non-volatile individually Myth__Buster <raghavanil4m@gmail.com> - 2012-07-05 10:44 -0700
  Re: Clarification on the applicability of compile-time optimization to a  struct variable which encompasses a mixture of fields declared as volatile  and non-volatile individually pete <pfiland@mindspring.com> - 2012-07-05 14:59 -0400
    Re: Clarification on the applicability of compile-time optimization to a struct variable which encompasses a mixture of fields declared as volatile and non-volatile individually Myth__Buster <raghavanil4m@gmail.com> - 2012-07-07 12:53 -0700
  Re: Clarification on the applicability of compile-time optimization to a struct variable which encompasses a mixture of fields declared as volatile and non-volatile individually Ben Bacarisse <ben.usenet@bsb.me.uk> - 2012-07-05 23:22 +0100
    Re: Clarification on the applicability of compile-time optimization to a struct variable which encompasses a mixture of fields declared as volatile and non-volatile individually Uncle Steve <stevet810@gmail.com> - 2012-07-06 13:08 -0400
      Re: Clarification on the applicability of compile-time optimization to a struct variable which encompasses a mixture of fields declared as volatile and non-volatile individually Ian Collins <ian-news@hotmail.com> - 2012-07-07 09:20 +1200
        Re: Clarification on the applicability of compile-time optimization to a struct variable which encompasses a mixture of fields declared as volatile and non-volatile individually Uncle Steve <stevet810@gmail.com> - 2012-07-06 14:01 -0400
          Re: Clarification on the applicability of compile-time optimization to a struct variable which encompasses a mixture of fields declared as volatile and non-volatile individually Eric Sosman <esosman@ieee-dot-org.invalid> - 2012-07-06 18:11 -0400
            Re: Clarification on the applicability of compile-time optimization to a struct variable which encompasses a mixture of fields declared as volatile and non-volatile individually Uncle Steve <stevet810@gmail.com> - 2012-07-06 14:33 -0400
              Re: Clarification on the applicability of compile-time optimization to a struct variable which encompasses a mixture of fields declared as volatile and non-volatile individually Ian Collins <ian-news@hotmail.com> - 2012-07-07 11:29 +1200
                Re: Clarification on the applicability of compile-time optimization to a struct variable which encompasses a mixture of fields declared as volatile and non-volatile individually Uncle Steve <stevet810@gmail.com> - 2012-07-06 16:27 -0400
                Re: Clarification on the applicability of compile-time optimization to a struct variable which encompasses a mixture of fields declared as volatile and non-volatile individually Ian Collins <ian-news@hotmail.com> - 2012-07-07 12:37 +1200
                Re: Clarification on the applicability of compile-time optimization to a struct variable which encompasses a mixture of fields declared as volatile and non-volatile individually Uncle Steve <stevet810@gmail.com> - 2012-07-06 17:29 -0400
                Re: Clarification on the applicability of compile-time optimization to a struct variable which encompasses a mixture of fields declared as volatile and non-volatile individually Ian Collins <ian-news@hotmail.com> - 2012-07-07 15:50 +1200
                Re: Clarification on the applicability of compile-time optimization to a struct variable which encompasses a mixture of fields declared as volatile and non-volatile individually Uncle Steve <stevet810@gmail.com> - 2012-07-06 19:55 -0400
                Re: Clarification on the applicability of compile-time optimization to a struct variable which encompasses a mixture of fields declared as volatile and non-volatile individually Phil Carmody <thefatphil_demunged@yahoo.co.uk> - 2012-07-07 17:04 +0300
              Re: Clarification on the applicability of compile-time optimization to a struct variable which encompasses a mixture of fields declared as volatile and non-volatile individually Tim Rentsch <txr@alumni.caltech.edu> - 2012-07-07 00:10 -0700
                Re: Clarification on the applicability of compile-time optimization to a struct variable which encompasses a mixture of fields declared as volatile and non-volatile individually Gareth Owen <gwowen@gmail.com> - 2012-07-07 10:00 +0100
                Re: Clarification on the applicability of compile-time optimization to a struct variable which encompasses a mixture of fields declared as volatile and non-volatile individually Tim Rentsch <txr@alumni.caltech.edu> - 2012-07-07 10:55 -0700
                Re: Clarification on the applicability of compile-time optimization to a struct variable which encompasses a mixture of fields declared as volatile and non-volatile individually Joshua Maurice <joshuamaurice@gmail.com> - 2012-07-07 15:13 -0700
                Re: Clarification on the applicability of compile-time optimization to a struct variable which encompasses a mixture of fields declared as volatile and non-volatile individually Uncle Steve <stevet810@gmail.com> - 2012-07-07 04:40 -0400
                Re: Clarification on the applicability of compile-time optimization to a struct variable which encompasses a mixture of fields declared as volatile and non-volatile individually Phil Carmody <thefatphil_demunged@yahoo.co.uk> - 2012-07-07 17:20 +0300
                Re: Clarification on the applicability of compile-time optimization to a struct variable which encompasses a mixture of fields declared as volatile and non-volatile individually Tim Rentsch <txr@alumni.caltech.edu> - 2012-07-07 10:33 -0700
              Re: Clarification on the applicability of compile-time optimization to a struct variable which encompasses a mixture of fields declared as volatile and non-volatile individually Eric Sosman <esosman@ieee-dot-org.invalid> - 2012-07-07 08:16 -0400
                Re: Clarification on the applicability of compile-time optimization to a struct variable which encompasses a mixture of fields declared as volatile and non-volatile individually Uncle Steve <stevet810@gmail.com> - 2012-07-07 05:12 -0400
                Re: Clarification on the applicability of compile-time optimization to a struct variable which encompasses a mixture of fields declared as volatile and non-volatile individually Eric Sosman <esosman@ieee-dot-org.invalid> - 2012-07-07 09:24 -0400
                Re: Clarification on the applicability of compile-time optimization to a struct variable which encompasses a mixture of fields declared as volatile and non-volatile individually Uncle Steve <stevet810@gmail.com> - 2012-07-07 06:07 -0400
                Re: Clarification on the applicability of compile-time optimization to a struct variable which encompasses a mixture of fields declared as volatile and non-volatile individually Keith Thompson <kst-u@mib.org> - 2012-07-07 13:26 -0700
                Re: Clarification on the applicability of compile-time optimization to a struct variable which encompasses a mixture of fields declared as volatile and non-volatile individually Uncle Steve <stevet810@gmail.com> - 2012-07-07 16:04 -0400
                Re: Clarification on the applicability of compile-time optimization to a struct variable which encompasses a mixture of fields declared as volatile and non-volatile individually James Kuyper <jameskuyper@verizon.net> - 2012-07-09 11:14 -0400
          Re: Clarification on the applicability of compile-time optimization to a struct variable which encompasses a mixture of fields declared as volatile and non-volatile individually Joshua Maurice <joshuamaurice@gmail.com> - 2012-07-06 16:58 -0700
            Re: Clarification on the applicability of compile-time optimizationo to a struct variable which encompasses a mixture of fields declared as volatile and non-volatile individually Uncle Steve <stevet810@gmail.com> - 2012-07-06 17:20 -0400
              Re: Clarification on the applicability of compile-time optimizationo to a struct variable which encompasses a mixture of fields declared as volatile and non-volatile individually Joshua Maurice <joshuamaurice@gmail.com> - 2012-07-06 19:39 -0700
                Re: Clarification on the applicability of compile-time optimizationo to a struct variable which encompasses a mixture of fields declared as volatile and non-volatile individually Uncle Steve <stevet810@gmail.com> - 2012-07-06 18:54 -0400
                Re: Clarification on the applicability of compile-time optimizationo to a struct variable which encompasses a mixture of fields declared as volatile and non-volatile individually Joshua Maurice <joshuamaurice@gmail.com> - 2012-07-06 20:12 -0700
                Re: Clarification on the applicability of compile-time optimizationo to a struct variable which encompasses a mixture of fields declared as volatile and non-volatile individually Uncle Steve <stevet810@gmail.com> - 2012-07-06 19:25 -0400
                Re: Clarification on the applicability of compile-time optimizationo to a struct variable which encompasses a mixture of fields declared as volatile and non-volatile individually Joshua Maurice <joshuamaurice@gmail.com> - 2012-07-06 20:33 -0700
                Re: Clarification on the applicability of compile-time optimizationo to a struct variable which encompasses a mixture of fields declared as volatile and non-volatile individually Uncle Steve <stevet810@gmail.com> - 2012-07-06 19:47 -0400
            Re: Clarification on the applicability of compile-time optimization to a struct variable which encompasses a mixture of fields declared as volatile and non-volatile individually Jens Gustedt <jens.gustedt@loria.fr> - 2012-07-07 15:47 +0200
              Re: Clarification on the applicability of compile-time optimization to a struct variable which encompasses a mixture of fields declared as volatile and non-volatile individually Uncle Steve <stevet810@gmail.com> - 2012-07-07 06:58 -0400
                Re: Clarification on the applicability of compile-time optimization to a struct variable which encompasses a mixture of fields declared as volatile and non-volatile individually Philip Lantz <prl@canterey.us> - 2012-07-14 21:46 -0700
              Re: Clarification on the applicability of compile-time optimization to a struct variable which encompasses a mixture of fields declared as volatile and non-volatile individually Joshua Maurice <joshuamaurice@gmail.com> - 2012-07-07 16:19 -0700
                Re: Clarification on the applicability of compile-time optimization to a struct variable which encompasses a mixture of fields declared as volatile and non-volatile individually Jens Gustedt <jens.gustedt@loria.fr> - 2012-07-08 09:40 +0200
                Re: Clarification on the applicability of compile-time optimization to a struct variable which encompasses a mixture of fields declared as volatile and non-volatile individually James Kuyper <jameskuyper@verizon.net> - 2012-07-08 10:51 -0400
                Re: Clarification on the applicability of compile-time optimization to a struct variable which encompasses a mixture of fields declared as volatile and non-volatile individually Philip Lantz <prl@canterey.us> - 2012-07-13 23:25 -0700
                Re: Clarification on the applicability of compile-time optimization to a struct variable which encompasses a mixture of fields declared as volatile and non-volatile individually Joshua Maurice <joshuamaurice@gmail.com> - 2012-07-14 14:37 -0700
                Re: Clarification on the applicability of compile-time optimization to a struct variable which encompasses a mixture of fields declared as volatile and non-volatile individually Joshua Maurice <joshuamaurice@gmail.com> - 2012-07-14 14:46 -0700
                Re: Clarification on the applicability of compile-time optimization to a struct variable which encompasses a mixture of fields declared as volatile and non-volatile individually Philip Lantz <prl@canterey.us> - 2012-07-14 21:39 -0700
    Re: Clarification on the applicability of compile-time optimization to a struct variable which encompasses a mixture of fields declared as volatile and non-volatile individually Tim Rentsch <txr@alumni.caltech.edu> - 2012-07-06 17:24 -0700
      Re: Clarification on the applicability of compile-time optimization to a struct variable which encompasses a mixture of fields declared as volatile and non-volatile individually Ben Bacarisse <ben.usenet@bsb.me.uk> - 2012-07-07 02:33 +0100
    Re: Clarification on the applicability of compile-time optimization to a struct variable which encompasses a mixture of fields declared as volatile and non-volatile individually Myth__Buster <raghavanil4m@gmail.com> - 2012-07-07 12:53 -0700

csiph-web