Philip Guenther wrote: > So what's protecting the state that you're waiting for the change to > occur in? If it's the mutex, then why are you accessing it with only > the rwlock early on? If it's the rwlock then how to prevent a > lost-wakeup by a thread on another CPU getting in between the > rw_exit() and msleep() and calling wakeup() in that window? That code > would only work reliably if you held *both* the mutex and the rwlock > when making changes to the state, or both the mutex and the big-lock. > Either way, what's the point of the rwlock there?
In this case, the mutex protects the sleep condition/wakeup, while the rwlock protects whatever else it protects. Something like the lockmgr interlock. I imagine there are really two states here, the 'internal' state for which we require locking, and the 'external' state which we sleep/wakeup for. But i'm just yammering.
