VirtualBox

Changeset 2105 in vbox


Ignore:
Timestamp:
Apr 16, 2007 3:08:48 PM (18 years ago)
Author:
vboxsync
Message:

sync virt time docs and some general docs updates.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/VMM/TM.cpp

    r2056 r2105  
    2323/** @page pg_tm        TM - The Time Manager
    2424 *
    25  * The Time Manager abstracts the CPU clocks and manages timers used by VM device.
    26  *
    27  *
    28  *
     25 * The Time Manager abstracts the CPU clocks and manages timers used by the VMM,
     26 * device and drivers.
     27 *
     28 *
     29 * @section sec_tm_clocks   Clocks
     30 *
     31 * There are currently 4 clocks:
     32 *   - Virtual (guest).
     33 *   - Synchronous virtual (guest).
     34 *   - CPU Tick (TSC) (guest). Only current use is rdtsc emulation. Usually a
     35 *     function of the virtual clock.
     36 *   - Real (host). The only current use is display updates for not real
     37 *     good reason...
     38 *
     39 * The interesting clocks are two first ones, the virtual and synchronous virtual
     40 * clock. The synchronous virtual clock is tied to the virtual clock except that
     41 * it will take into account timer delivery lag caused by host scheduling. It will
     42 * normally never advance beyond the header timer, and when lagging too far behind
     43 * it will gradually speed up to catch up with the virtual clock.
     44 *
     45 * The CPU tick (TSC) is normally virtualized as a function of the virtual time,
     46 * where the frequency defaults to the host cpu frequency (as we measure it). It
     47 * can also use the host TSC as source and either present it with an offset or
     48 * unmodified. It is of course possible to configure the TSC frequency and mode
     49 * of operation.
     50 *
     51 * @subsection subsec_tm_timesync Guest Time Sync / UTC time
     52 *
     53 * Guest time syncing is primarily taken care of by the VMM device. The principle
     54 * is very simple, the guest additions periodically asks the VMM device what the
     55 * current UTC time is and makes adjustments accordingly. Now, because the
     56 * synchronous virtual clock might be doing catchups and we would therefore
     57 * deliver more than the normal rate for a little while, some adjusting of the
     58 * UTC time is required before passing it on to the guest. This is why TM provides
     59 * an API for query the current UTC time.
     60 *
     61 *
    2962 * @section sec_tm_timers   Timers
    3063 *
    31  * The timers supports multiple clocks. Currently there are two clocks in the
    32  * TM, the host real time clock and the guest virtual clock. Each clock has it's
    33  * own set of scheduling facilities which are identical but for the clock source.
    34  *
    35  * Take one such timer scheduling facility, or timer queue if you like. There are
    36  * a few factors which makes it a bit complex. First there is the usual GC vs. HC
    37  * thing. Then there is multiple threads, and then there is the fact that on Unix
    38  * we might just as well take a timer signal which checks whether it's wise to
    39  * schedule timers while we're scheduling them. On API level, all but the create
    40  * and save APIs must be mulithreaded.
    41  *
    42  * The design is using a doubly linked HC list of active timers which is ordered
    43  * by expire date. Updates to the list is batched in a singly linked list (linked
    44  * by handle not pointer for atomically update support in both GC and HC) and
    45  * will be processed by the emulation thread.
    46  *
    47  * For figuring out when there is need to schedule timers a high frequency
    48  * asynchronous timer is employed using Host OS services. Its task is to check if
    49  * there are anything batched up or if a head has expired. If this is the case
    50  * a forced action is signals and the emulation thread will process this ASAP.
    51  *
     64 * The timers can use any of the TM clocks described in the previous section. Each
     65 * clock has its own scheduling facility, or timer queue if you like. There are
     66 * a few factors which makes it a bit complex. First there is the usual R0 vs R3
     67 * vs. GC thing. Then there is multiple threads, and then there is the timer thread
     68 * that periodically checks whether any timers has expired without EMT noticing. On
     69 * the API level, all but the create and save APIs must be mulithreaded. EMT will
     70 * always run the timers.
     71 *
     72 * The design is using a doubly linked list of active timers which is ordered
     73 * by expire date. This list is only modified by the EMT thread. Updates to the
     74 * list are are batched in a singly linked list, which is then process by the EMT
     75 * thread at the first opportunity (immediately, next time EMT modifies a timer
     76 * on that clock, or next timer timeout). Both lists are offset based and all
     77 * the elements therefore allocated from the hyper heap.
     78 *
     79 * For figuring out when there is need to schedule and run timers TM will:
     80 *    - Poll whenever somebody queries the virtual clock.
     81 *    - Poll the virtual clocks from the EM and REM loops.
     82 *    - Poll the virtual clocks from trap exit path.
     83 *    - Poll the virtual clocks and calculate first timeout from the halt loop.
     84 *    - Employ a thread which periodically (100Hz) polls all the timer queues.
     85 *
    5286 */
    5387
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette