Xen中要维持两种时间
- 真实时间(wall-clock time)
想想Windows右下角的那个时间,或者家里墙上的钟表,可能就理解这个wall-clock time了 - 虚拟时间(virtual time)
客户机运行的时间
为什么需要虚拟时间呢? 《The definitive guide to the Xen hypervisor》中有一段很好地解释:
“Virtual time is essential for scheduling of tasks running within a domain. Consider the case of two domains running on the same machine, each of which is scheduled for 10ms at a time. If each domain is running two tasks, and scheduling them for 10ms each using wall time, then one task in each domain will get half of the real CPU’s time and the other one will get none.”
我是这样理解的,假如我的机器上同时运行着两个客户机(客户机A,客户机B),Xen的管理程序采用时间片轮转来调度这两个客户机(时间片为10毫秒),客户机A上运行着两个任务(t1, t2),客户机A也恰好也采用时间片轮转来调度这两个任务,无独有偶,时间片也恰好是10毫秒。
假如11点11分11秒00毫秒时,A客户机开始运行(t1运行,t2挂起),B客户机挂起
那么11点11分11秒10毫秒时,B客户机开始运行,A客户机挂起
于是11点11分11秒20毫秒时,假如采用真实时间调度的话,问题就来了,A客户机一看,现在是11点11分11秒20毫秒,又应该调度t1了。
……如此继续下去,t2的结局只能是饿死!
为什么会酱紫呢?可能是客户机A