Il 20/09/2012 10:09, liu ping fan ha scritto: > > > > No, MMIO dispatch has to discard the fine-grained lock before acquiring > > the big lock. > > This will cause the device state broken, and expose device under changing > risk.
We do it all the time with asynchronous I/O. It's just an invariant that fine-grain-locked devices have to obey. You cannot keep the same semantics you enjoyed when a single lock covered everything. > > If you allow > > > > lock(fine) > > lock(coarse) > > > > then the (presumably higher-priority) thread that is requesting the > > fine-grained lock must wait for the lower-priority thread that holds the > > coarse-grained lock. Then you get priority inversion. > > Which thread has higher-priority? Why does the thread with coarse lock > have lower-priority? Because there can be so many things happening under the coarse lock, that just _assuming_ it has lower priority is a good thing. On the other hand, if the device didn't need immediate servicing (which means higher priority), you wouldn't bother taking it out of the big QEMU lock. Paolo