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

Back to Subject List

Old thread has been locked -- no new posts accepted in this thread
???
04/21/07 00:00
Read: times


 
#137681 - atomicity
Responding to: ???'s previous message
I don't think this falls into the atomic category. (Although it blew up in my face.)

As I understand it, "atomic operations" ensure that nothing can change a variable as you're operating on it. The is important if you're accessing a 16-bit variable on an 8-bit machine. For instance, something like:
unsigned int foo, bar;
void main(void) {
    foo = 2;
    bar = foo;
} // main
The issue here is that there's no simple one-step move operation that copies bletch into snafu. Both variables require more than one access (one to get the lower-order byte and copy it, one to get the higher-order byte and do same). If an interrupt came along and modified foo during the copy operation, you'd get a wrong answer.

We know the solution to this is to disable interrupts around the copy.

But I'm not sure if my example is really "atomic." Maybe it's semantic hair-splitting.

I guess that disabling interrupts in the isUartEOL() function would have solved the problem.

-a

List of 12 messages in thread
TopicAuthorDate
lesson learned            01/01/70 00:00      
   "atomic"            01/01/70 00:00      
      atomicity            01/01/70 00:00      
      if thatb is so            01/01/70 00:00      
         Indeed            01/01/70 00:00      
   Bit test and clear            01/01/70 00:00      
      JBC            01/01/70 00:00      
         favourite atomic test-and-set instructions            01/01/70 00:00      
      SDCC also            01/01/70 00:00      
         Classic atomic problem            01/01/70 00:00      
            and/or ...            01/01/70 00:00      
   another example            01/01/70 00:00      

Back to Subject List