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 16:03
Read: times


 
#130432 - C extensions
Responding to: ???'s previous message
Dan Henry said:
Same as assembly, sometimes we take care of it without disabling interrupts by recognizing when an ISR has modified the multibyte variable. There are several ways to do this depending on how the variable changes, but one generic method is to associate a 'dirty' bit with the variable. The ISR always sets the dirty bit when it modifies the variable. The non-ISR code clears the dirty bit, reads the variable, then checks the dirty bit and if set, repeats until it gets a clean read.


Good point, thanks. Of course, there are many ways... As Erik mentioned above, sometimes it is easier to avoid the problem altogether. On the other hand, the "atomicity" problem may exhibit itself also in a different - and more subtle, whence more dangerous - way: if two or more distinct variables (all of which are modified in an atomic way) have to . The typical problem is with values within (ring) buffer and the pointer pointing to them... These cannot be detected generally.

However, the multibyte variable _can_be treated at least up to a warning - and I think it's worth add at this level of "built-in intelligence" to a tool which is supposed to _help_ ... :-)

Standard C does not provide any means for what you are asking. Some extended Cs might.

I doubt a warning would violate any C standard.

Of course the automatic "treatment" would, but, anyway, any '51- (and also any other mcu-) specific C compiler is NOT adhering perfectly to the standards by definition, in order to be of any use...

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