This FIFO trick won't work on an SMP system, because both threads may run simultaneously on different processors. You'll have to use the more proper thread synchronization primitives (e.g., a mutex), or use BMP to tie the threads to specific CPUs.
Obviously, this scheme breaks down in a multicore system, because again the thread and the ISR could be running on different processors.
The solution in this case is to use the InterruptLock() and InterruptUnlock() calls to ensure that the ISR won't preempt the thread at an unexpected point. But what if the thread preempts the ISR? The solution is the same: use InterruptLock() and InterruptUnlock() in the ISR as well.
Function | Operation |
---|---|
atomic_add() | Add a number |
atomic_add_value() | Add a number and return the original value of *loc |
atomic_clr() | Clear bits |
atomic_clr_value() | Clear bits and return the original value of *loc |
atomic_set() | Set bits |
atomic_set_value() | Set bits and return the original value of *loc |
atomic_sub() | Subtract a number |
atomic_sub_value() | Subtract a number and return the original value of *loc |
atomic_toggle() | Toggle (complement) bits |
atomic_toggle_value() | Toggle (complement) bits and return the original value of *loc |