- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello,
I'm trying to figure out how can one check what is the reason for the MWAIT to wakeup.
I know there are several reasons for MWAIT to wakeup, including a write to the monitored address (of course, and to rule out this specific reason is obvious), interrupts, faults and signals.
What I'm trying to figure out exactly is how can you know which FAULT/INTERRUPT/SIGNAL woke you up?
It is not written in the manuals or anything.
Thanks in advance.
- Tags:
- Intel® Advanced Vector Extensions (Intel® AVX)
- Intel® Streaming SIMD Extensions
- Parallel Computing
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
What I'm trying to figure out exactly is how can you know which FAULT/INTERRUPT/SIGNAL woke you up?
There is no way to discover this. I think the problem here is that your mental model of how mwait is used is wrong. Mwait is not a communication mechanism, it doesn't ever tell you that some condition on which you wanted to wait has occurred. Rather, it is a way of sleeping efficiently that will wake up at a time when it's likely that it's worth checking the condition. So you should think of mwait finishing as a suggestion that you should check the condition your're waiting for, not as a guarantee that the condition is true.
Therefore code using mwait looks something like this
// Wait for *target to be non-zero static void mwaitForNonZero(uint32_t volatile * target) { while (*target == 0) { _mm_monitor ((void *)target, 0, 0); if (*target != 0) /* Avoid race if *target changes after the while but before the monitor */ break; _mm_mwait (0, 0); } }

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page