Patent ID: 8266629
Filing Date: 2012-09-11
Classification: G06F

Abstract:
1. A virtual machine system comprising: a physical CPU; a virtual machine hypervisor which logically divides the physical CPU to obtain a plurality of virtual machines; and a virtual machine control memory which is used by the virtual machine hypervisor to control the virtual machines, wherein: the virtual machines have a CPU sharing mode that the physical CPU is shared among the plural virtual machines, and a CPU occupancy mode that a predetermined virtual machine among the plural virtual machines occupies the physical CPU; the physical CPU has an internal memory for storing a physical context corresponding to a process under execution; the virtual machine control memory has a logical context area corresponding to the physical context; the process is any one of a first logical CPU process which is a process of a logical CPU of the virtual machine, a second logical CPU process which is a process of a logical CPU of a virtual machine for the virtual machine hypervisor, and a control process of the virtual machine hypervisor; the virtual machine hypervisor has a process control block for managing a saving operation of the physical context to the logical context area when processes of the virtual machines are switched; when the virtual machine hypervisor selects the control process as a next process, the virtual machine hypervisor determines whether or not a process under execution in the physical CPU is any one of the first logical CPU process and the second logical CPU process; in a case that the process under execution is the first logical CPU process of the CPU occupancy mode according to the determination, the virtual machine hypervisor turns ON a suspending flag of the process control block which suspends saving of a physical context corresponding to the process under execution; in a case that the process under execution is the first logical CPU process of the CPU sharing mode according to the determination, the virtual machine hypervisor turns OFF the suspending flag of the process control block which suspends saving of the physical context corresponding to the process under execution, and saves the physical context corresponding to the first logical CPU process of the CPU sharing mode to the corresponding logical context area; in a case that the process under execution is the second logical process according to the determination, the virtual machine hypervisor turns OFF the suspending flag of the process control block which suspends saving of the physical context corresponding to the process under execution, and saves the physical context corresponding to the second logical CPU process to the corresponding logical context area; when the virtual machine hypervisor selects the first logical CPU process as a next process of the control process, the virtual machine hypervisor refers to the suspending flag in the logical CPU process executed before the control process; in a case that the referred suspending flag is turned ON, the physical CPU executes the first logical CPU process of the CPU occupancy mode by referring to the physical context of the internal memory, saving of which is suspended, and turns OFF the suspending flag referred to by the virtual machine hypervisor; in a case that the referred suspending flag is turned OFF, the virtual machine hypervisor restores a physical context from the logical context area into the internal memory, the physical context corresponding to the first logical CPU process of the CPU sharing mode, and the physical CPU executes the first logical CPU process of the CPU sharing mode by referring to the restored physical context corresponding to the first logical CPU process of the CPU sharing mode; when the virtual machine hypervisor selects the second logical CPU process as a next process of the control process, the virtual machine hypervisor refers to the suspending flag in the logical CPU process executed before the control process; in a case that the referred suspending flag is turned ON, the virtual machine hypervisor saves the physical context of the internal memory, saving of which is suspended, into the corresponding logical context area, and turns OFF the referred suspending flag, the virtual machine hypervisor restores a physical context corresponding to the second logical CPU process from the logical context area into the internal memory, the physical CPU executes the second logical CPU process by referring to the restored physical context corresponding to the second logical CPU process; and in a case that the referred suspending flag is turned OFF, the virtual machine hypervisor restores a physical context corresponding to the second logical CPU process from the logical context area into the internal memory, and the physical CPU executes the second logical CPU process by referring to the restored physical context corresponding to the second logical CPU process.