mirage/mirage-platform — pull request #58 by djs55 (2013-09-19 21:26:53+00:00)
Title: (careful review and test required): turn on async interrupts instead of polling

The strategy is:
* we leave all event channels unmasked
* we enable and disable event delivery globally using the evtchn_upcall_mask
* all we do in the hypervisor_callback is clear the evtchn_upcall_pending (to acknowledge that we've received the callback)
* after the hypervisor_callback is called, any running SCHEDOP_block returns and we call evtchn_poll as before, checking the individual event channel pending bits
* instead of waking up threads in a per-event channel sequence we keep a counter per channel, allowing waiting threads to block elsewhere and come back, safe in the knowledge that they won't "miss" an event
* for timeouts we bind the timer VIRQ and set the timeout before calling SCHEDOP_block