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
  • I.e. you need an atomic instruction to work around the lack of an atomic instruction. Chicken/Egg, here we come!

    Only if you do things like disabling interrupts in an ISR without re-enabling them before leaving the ISR, or your processor has an interrupt system where there's a window after disabling interrupts in which interrupts can still occur.

    And even the venerable 8051 has an atomic "jump if bit is set and clear bit" instruction.

Reply
  • I.e. you need an atomic instruction to work around the lack of an atomic instruction. Chicken/Egg, here we come!

    Only if you do things like disabling interrupts in an ISR without re-enabling them before leaving the ISR, or your processor has an interrupt system where there's a window after disabling interrupts in which interrupts can still occur.

    And even the venerable 8051 has an atomic "jump if bit is set and clear bit" instruction.

Children
No data