This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Atomicity

Is the operation below an atomic operation in a multitasking environment like RTX-51? If it is not, then what is supposed to do to make it an atomic one except using locking mechanisms?

void func()
{
  int locVal = globalVal++;
  ...
  ...
}

Parents
  • "The trouble being that in general you have to save the previous state of the interrupt-enable flag before you disable interrupts [...]".

    From my second post in this thread "This is similar to disabling interrupts, but with an automatic enable, and the program doesn't need to know if interrupts was enabled or disabled when processing the lock instruction or processing instructions with lock flags."

    But as noted by Christoph Franck, you seldom have a problem with the atomicity of caching the interrupt flag state before turning off interrupts. The problem is more often the number of instructions needed.

Reply
  • "The trouble being that in general you have to save the previous state of the interrupt-enable flag before you disable interrupts [...]".

    From my second post in this thread "This is similar to disabling interrupts, but with an automatic enable, and the program doesn't need to know if interrupts was enabled or disabled when processing the lock instruction or processing instructions with lock flags."

    But as noted by Christoph Franck, you seldom have a problem with the atomicity of caching the interrupt flag state before turning off interrupts. The problem is more often the number of instructions needed.

Children