Optimize the mutex code in a few ways:
- Split the fast and slow paths into their own functions, inline the fast path.
- Raise IPL only when acquiring a turnstile lock.
- Avoid taking the turnstile lock if the "waiters" bit is not set.
- Do adaptive spinning only when the lock owner is running.