Domains are preemptively scheduled by Xen according to the
parameters installed by domain 0 (see Section A.10).
In addition, however, a domain may choose to explicitly
control certain behavior with the following hypercall:
sched_op(unsigned long op)
Request scheduling operation from hypervisor. The options are: SCHEDOP_yield, SCHEDOP_block, and SCHEDOP_shutdown.
yield keeps the calling domain runnable but may cause a
reschedule if other domains are runnable. block removes the
calling domain from the run queue and cause is to sleeps until an
event is delivered to it. shutdown is used to end the domain's
execution; the caller can additionally specify whether the domain
should reboot, halt or suspend.
To aid the implementation of a process scheduler within a guest OS,
Xen provides a virtual programmable timer:
set_timer_op(uint64_t timeout)
Request a timer event to be sent at the specified system time (time
in nanoseconds since system boot). The hypercall actually passes the
64-bit timeout value as a pair of 32-bit values.
Note that calling set_timer_op() prior to sched_op
allows block-with-timeout semantics.