Patent ID: 7788664

Claim:
A method of virtualizing a counter in a computer system comprising the steps of: a virtual machine monitor: programming a hardware event counter with an initial count which is a specific count number that must be reached before the hardware event counter generates an interrupt for a profiling event for a virtual machine; and iteratively performing the steps of: using a virtual machine monitor to suspend operation of the virtual machine while processor time and memory space is allocated to another virtual machine, and upon suspending operation of the virtual machine, saving a suspension count representing a then present count number of the hardware event counter and disabling the hardware event counter; upon resuming the operation of the virtual machine, programming the hardware event counter with the suspension count; and upon receiving an interrupt to the virtual machine from the hardware event counter that provides notification of reaching the initial count: saving a sample that comprises an event identifier identifying an event type of the profiling event and a code-in-execution indicator representing an instruction that was executing when the initial count was reached; and reprogramming the hardware event counter with the initial count.