111I.®@@ , Iw J , J '5 Expected 5 Expected 3 a Return to Timer :Ltimer Firings Normal Mode Duration W '5 L Expected 7 Timer Firings,Y Received 3
Total Page:16
File Type:pdf, Size:1020Kb
US008533709B2 (12) United States Patent (10) Patent No.: US 8,533,709 B2 Nicholas et al. (45) Date of Patent: Sep. 10, 2013 (54) VIRTUALCHANGINGPROGRAMMABLE MACHINES FREQUENCY INTERRUPT T0 CONTROL OFAVIRTUAL TIMER IN 200336614073232006/0090092 A1 * 4/2006 Verhulstgakdiinentetlai‘if n e ......................a ' "" ~~~~~~~~~~~~ " ~~.. 713/400 VIRTUAL TIME OTHER PUBLICATIONS . Mock et a1. “Continuous clock s chroniZation in Wireless real-time (75) Inventors: Andrew Ernest Nicholas’ Beinevue’ WA applications”, Reliable Distributzid1 Systems, 2000, p. 125-132).* (Us); Rene Anton“) Vega’ Klrkland’ WA Cristian et a1. (“Clock Synchronization in the Presence of Omission (Us) and Performance Failures, and Processor Joins”, IBM Research, 16th IEEE Int. Symp. On Fault-tolerant Computing Systems, Vienna, Jul. (73) Assignee: Microsoft Cororation, Redmond, WA 19g6),* (US) Honeycutt, J., “Microsoft® Virtual PC”, Microsoft®, Nov. 2003, 1-27. ( * ) Notice: Subject to any disclaimer, the term of this patent is extended or adjusted under 35 * Cited by examiner U.S.C. 154(b) by 1649 days. Primary Examiner * Meng An (21) Appl. No.1 11/197,614 Assistant Examiner * Eric C Wai (74) Attorney, Agent, or Firm * Woodcock Washburn, LLP (22) Filed: Aug. 4, 2005 (57) ABSTRACT (65) Prior Publication Data . A catch-up mode that runs a v1rtua1 programmable rnterrupt US 2007/0033589 A1 Feb. 8, 2007 timer faster than a nominal rate to prevent time loss in a virtual machine can be implemented. If time loss is determined, a (51) Int- Cl- catch-up mode can be initiated to cause increased ?rings, G06F 9/45 5 (2006-01) beyond a nominal rate, of the programmable interrupt timer to (52) US Cl- adjust the clock of the virtual machine to the clock of the host USPC ............................................................ .. 718/1 System_ The Virtual programmable interrupt timer can also be (58) Field of Classi?cation Search readjusted to a predetermined nominal rate When the time loss USPC ............................ .. 719/321; 718/1; 713/400 in the guest operating system is determined approximately See application ?le for complete search history. Within a predetermined tolerance range. The catch-up mode can be monitored to avoid “interrupt storms” on the virtual (56) References Cited machine. The virtual programmable interrupt timer can be altered by the guest operating system to accommodate differ US. PATENT DOCUMENTS ent operating systems. 4,772,966 A * 9/1988 Sharples et a1. ............ .. 386/207 6,212,574 B1* 4/2001 O’Rourke et a1. .......... .. 719/321 16 Claims, 5 Drawing Sheets Virtual Machine Timer Sequence With Catch-Up Mode Next Scheduled Fire Time Using Normal Mode Using Catch-Up Mode Using Normal Mode A M I I f T ) Fire Fire Fire Fire Firin Firing _____ I@@@@®@@@@ i l , ll _ , 111i.®@@ , iw_J , j '5 Expected 5 Expected 3 a Return TO Timer :LTimer Firings Normal Mode Duration w '5 L Expected 7 Timer Firings,Y Received 3 Expected 8 Timer Firings, Received 8 US. Patent Sep. 10, 2013 Sheet 1 of5 US 8,533,709 B2 US. Patent Sep. 10, 2013 Sheet 4 of5 US 8,533,709 B2 410 Host Operating System 420 430 40 Guest Operating Guest Operating Guest Operating System System System 450 460 Guest Operating Guest Operating System System 470 Figure 4 v Guest Operating System US. Patent Sep. 10, 2013 Sheet 5 of5 US 8,533,709 B2 505 I ' Virtual l 510 machine Wait for Host running on timer I Host machine ‘ expiration (firing) 515 We T'ie lapse between expected timer expiration time and actual timer predetermined tolerance? Nv° 525 Initiate "catch up" mode to correct time loss + 530 550 Increase rate Resume of?rings for nominal Host Host timer timer rate 535 Receive ‘ 540 r feedback from Determine if 9ue$_t —> suf?cient firings Operating l-v occurred to “catch syfstem to up" time on guest V9"? guest ' operating system me No 545 apse withi predetermined tolerance? Figure 5 US 8,533,709 B2 1 2 CHANGING FREQUENCY OF A VIRTUAL In another method, the host operating system determines PROGRAMMABLE INTERRUPT TIMER IN the location of the “clock” updated by the programmable VIRTUAL MACHINES TO CONTROL interrupt timer interrupt handler in the guest operating system VIRTUAL TIME to prevent drifting. This method required intimate knoWledge of the “clock” location in the guest memory for a speci?c BACKGROUND guest operating system. This method, therefore, had to use an added guest component to discover the “clock” location to Some x86 guest operating systems (OS) implement peri enlighten the guest operating system of the clock position. odic timing as the means to create a software stepping signal The location of the “clock” in the guest memory Was then to update their time of day counters. These operating systems transmitted to the host so that the clock Was updated directly. use the programmable interrupt timer to interrupt or ?re at a This method Was also de?cient because it required multiple predictable rate and update the operating system counter that changes to be made to the guest operating system. Further, the is used to keep track of elapsed time. Time for an operating “clock” position varied in the different operating systems system can be maintained by a kernel clock and the time-of requiring additional components to be created for each oper day clock. The time-of-day clock is derived from the kernel ating system. This method Would be highly unpractical today clock unless the time-of-day clock is externally modi?ed, for Where there is a plurality of operating systems, in contrast to example, by a user. If for example, the time-of-day clock is the past When there Were only a feW operating systems. externally modi?ed, the kernel clock Will not track the time In yet another method, a component of the guest operating of-day clock, but Will remain unchanged. A virtualiZation system Was modi?ed to request the precise elapsed time from service creates a virtual programmable interrupt timer, one or 20 the virtual machine. This method alloWed enlightened guest more for each virtual machine, and the virtual programmable operating systems to maintain precise, correct time. This interrupt timer relies on a regular, periodic host operating method, hoWever, required guest x86 operating systems to system callback mechanism to accurately emulate the pro either request the correct time from the host or have the guest grammable interrupt timer for the virtual machines. “advertise” the memory location of its operating system When the real programmable interrupt timer hardWare is 25 “clock.” This method Was de?cient because it required addi virtualiZed, the software virtualiZation is not in control of tional code to inform the operating system of the location of certain aspects of its operating environment. For example, the the clock. Thus, this method, too, required modi?cation of the virtualiZation service implementing the virtual program guest operating system that Would be unpractical today With mable interrupt timer may be preempted by other ho st activity the plurality of operating systems in use. causing the virtual system to have non-deterministic timing 30 Moreover, a method Was invented Where the steering infor behavior. The virtual machines may also be preempted either mation from the guest operating system Was communicated by host activity or by other virtual machines executing in the to the virtualiZation service. Speci?cally, the clock time same physical system. Consequently, there may be periods of inside the guest operating system Was transmitted periodi time When a virtual programmable interrupt timer interrupt cally to the virtualiZation service. This method alloWed the presented to the virtual machine may be delayed past the next 35 virtual service to calculate the difference in clock time expected timer period and effectively merged With the next betWeen the guest operating system and host operating sys virtual programmable interrupt timer interrupt. If this occurs, tem so that the clock could be updated. This method Was also the virtual programmable interrupt timer may appear to “lose de?cient because a small amount of time loss or drift time” With respect to the actual time as the interrupt arrival remained even after correction by this method. rate becomes less than nominal. The amount of time loss in 40 In vieW of the foregoing, there is a need to overcome the the virtual programmable interrupt timer can range from a limitations, draWbacks, and de?ciencies of the prior art. feW seconds every minute With a light processor load on the host to a majority of the time every minute With heavy pro SUMMARY cessor loads on the host machine. The greater the loss, the more problems the virtual machine Will face in operation. 45 The folloWing summary provides an overvieW of various Several methods have been used in the past to keep more aspects of the invention. It is not intended to provide an accurate time in a virtual machine. For example; Microsoft exhaustive description of all of the aspects of the invention, Virtual PC implemented a method that involved a guest oper nor to de?ne the scope of the invention. Rather, this summary ating system component periodically requesting the current is intended to serve as an introduction to the detailed descrip time from the ho st and subsequently setting the correct exter 50 tion and ?gures that folloW. nally visible time in the guest operating system. The guest The accuracy of time as perceived by the guest virtual operating system Was informed by the host hoW often and machine is signi?cantly improved. An example method Whether or not to apply time correction along With the thresh solves the problem of excessive time loss (drift) Within a old of time-drift Which should have a trigger setting a time virtual machine (V M).