Email: Password: Remember Me | Create Account (Free)

Back to Subject List

Old thread has been locked -- no new posts accepted in this thread
???
01/08/07 21:26
Read: times


 
#130456 - questions and answers
Responding to: ???'s previous message
Neil Kurzman said:
Let use say the compiler disables interupts to make an operation atomic "automaticlly". Now it must keep track of other disables as not to screw up the state. [...]

To disable interrupts when manipulating a "critical" variable is none the worse than the present state, when whole functions are disabled (by explicit use of appropriate pragma in both compilers) when they contain operations with "critical" variables.
Neil Kurzman said:
But you know the code / hardware will never let it interfere. Now what to disable all interupts, one or two of them?
Maybe a bit flag as a semiphore is better. which to use? how to tell the compiler leave it alone I have this one?

Maybe I won't answer all your questions, but I try at least:
  1. first step is to implement "critical" as a keyword for variables; using these in "main" would (note, the user assigns the variable as "critical")
  2. second step is to detect "possibly critical" variables and issue a warning (this can be suppressed using appropriate pragma - there are a lot of such warning-suppressing pragmas in all C-compilers)
  3. third, a possibly dangerous step is to switch on the automatic "critical" flagging, but this would be by default off and potentially locally suppressable - OK this can be completely omitted if you think it brings more trouble than help
  4. anyway, I'd implement the "disable" and "enable" as a macro or a function (possibly inlined), so that the user can override it as he wishes
I wouldn't be afraid of "incomplete non-atomicity detection" accusations, if this all is properly documented and if the warning says something like "possibly critical variable" or so. I have seen a lot of such automatic detection and warning on e.g. of "unused" variables, which can be easily cheated, and nobody complains.

I think people are happy if they are helped and I believe even seasoned programmers like to be helped. I might be wrong of course, due to my innate naivity and stupidity :-)

JW



List of 32 messages in thread
TopicAuthorDate
atomicity, multibyte variables, C and my comfort            01/01/70 00:00      
   No way            01/01/70 00:00      
      Well, theoretically ...            01/01/70 00:00      
   Yes sdcc at least            01/01/70 00:00      
      Keil            01/01/70 00:00      
   Does it matter?            01/01/70 00:00      
      sort of...            01/01/70 00:00      
         Lack of this feature ...            01/01/70 00:00      
            really?            01/01/70 00:00      
   talking out of both sides of the mouth            01/01/70 00:00      
      :-)            01/01/70 00:00      
         the simple solution            01/01/70 00:00      
            The question was not how to fix it...            01/01/70 00:00      
   Don't disable            01/01/70 00:00      
      C extensions            01/01/70 00:00      
         ring buffer, atomicity and C            01/01/70 00:00      
            OK that was a stupid example...            01/01/70 00:00      
      Hardware solution called for            01/01/70 00:00      
         isn't HLL supposed to hide the low level details?            01/01/70 00:00      
            the skinny            01/01/70 00:00      
               Word length & Atomicity            01/01/70 00:00      
            Side effects            01/01/70 00:00      
               questions and answers            01/01/70 00:00      
                  Embedded Specific            01/01/70 00:00      
                     Neil, you GOT it            01/01/70 00:00      
                        waitaminute...            01/01/70 00:00      
                           from an old hand to a newbie            01/01/70 00:00      
                              what helps is good (?)            01/01/70 00:00      
                                 The warning you propose would be 'wrong' in some c            01/01/70 00:00      
                                    wrong warnings            01/01/70 00:00      
                                       Read-Modify-Write            01/01/70 00:00      
                                          OK then not simple            01/01/70 00:00      

Back to Subject List