Joerg Sonnenberger wrote:
According to the AMD documentation, MWAIT would exit because:
Events that cause an exit from the monitor event pending state include:
...
- Any far control transfer that occurs between the MONITOR and the MWAIT.
The exact conditions are written in the Architecture Guide, part 3. It
should be noted that a number of Opteron CPUs have an errata if you use
MONITOR/MWAIT in a tight loop and certain race conditions with other
CPUs happen and you have interrupts disabled. It should also be noted
that MWAIT produces less bus contention as well, so it should be used
for all spinlocks.
Using it for spinlocks is rather easy, because there is just one variable to
monitor. The intel docs also indicate that there can be a MWAIT functionality
to work with interrupts disabled and as interrupt as a break condition. I'm
not exactly sure how this would work, maybe the interrupt would be serviced as
soon as you enable interrupts again?
cheers
simon