~ubuntu-branches/ubuntu/raring/virtualbox-ose/raring

« back to all changes in this revision

Viewing changes to src/VBox/VMM/VMMAll/TMAllVirtual.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Felix Geyer
  • Date: 2011-01-30 23:27:25 UTC
  • mfrom: (0.3.12 upstream)
  • Revision ID: james.westby@ubuntu.com-20110130232725-2ouajjd2ggdet0zd
Tags: 4.0.2-dfsg-1ubuntu1
* Merge from Debian unstable, remaining changes:
  - Add Apport hook.
    - debian/virtualbox-ose.files/source_virtualbox-ose.py
    - debian/virtualbox-ose.install
  - Drop *-source packages.
* Drop ubuntu-01-fix-build-gcc45.patch, fixed upstream.
* Drop ubuntu-02-as-needed.patch, added to the Debian package.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/* $Id: TMAllVirtual.cpp $ */
 
1
/* $Id: TMAllVirtual.cpp 35346 2010-12-27 16:13:13Z vboxsync $ */
2
2
/** @file
3
3
 * TM - Timeout Manager, Virtual Time, All Contexts.
4
4
 */
20
20
*   Header Files                                                               *
21
21
*******************************************************************************/
22
22
#define LOG_GROUP LOG_GROUP_TM
23
 
#include <VBox/tm.h>
 
23
#include <VBox/vmm/tm.h>
24
24
#ifdef IN_RING3
25
 
# include <VBox/rem.h>
 
25
# include <VBox/vmm/rem.h>
26
26
# include <iprt/thread.h>
27
27
#endif
28
28
#include "TMInternal.h"
29
 
#include <VBox/vm.h>
30
 
#include <VBox/vmm.h>
 
29
#include <VBox/vmm/vm.h>
 
30
#include <VBox/vmm/vmm.h>
31
31
#include <VBox/err.h>
32
32
#include <VBox/log.h>
33
33
#include <VBox/sup.h>
184
184
    {
185
185
        /*
186
186
         * We've expired the interval, cap it. If we're here for the 2nd
187
 
         * time without any GIP update inbetween, the checks against
 
187
         * time without any GIP update in-between, the checks against
188
188
         * pVM->tm.s.u64VirtualRawPrev below will force 1ns stepping.
189
189
         */
190
190
        u64Delta = u32UpdateIntervalTSC;
249
249
    /*
250
250
     * Attempt updating the previous value, provided we're still ahead of it.
251
251
     *
252
 
     * There is no point in recalculating u64NanoTS because we got preemted or if
 
252
     * There is no point in recalculating u64NanoTS because we got preempted or if
253
253
     * we raced somebody while the GIP was updated, since these are events
254
 
     * that might occure at any point in the return path as well.
 
254
     * that might occur at any point in the return path as well.
255
255
     */
256
256
    for (int cTries = 50;;)
257
257
    {
421
421
    STAM_COUNTER_INC(&pVM->tm.s.StatVirtualSyncGetLocked);
422
422
 
423
423
    /*
424
 
     * Don't make updates until we've check the timer qeueue.
 
424
     * Don't make updates until we've check the timer queue.
425
425
     */
426
426
    bool            fUpdatePrev = true;
427
427
    bool            fUpdateOff  = true;
676
676
     *    debugging the process.
677
677
     *  - We might be on a different CPU which TSC isn't quite in sync with the
678
678
     *    other CPUs in the system.
679
 
     *  - Another thread is racing us and we might have been preemnted while inside
 
679
     *  - Another thread is racing us and we might have been preempted while inside
680
680
     *    this function.
681
681
     *
682
682
     * Assuming nano second virtual time, we can simply ignore any intervals which has
906
906
/**
907
907
 * Gets the current TMCLOCK_VIRTUAL frequency.
908
908
 *
909
 
 * @returns The freqency.
 
909
 * @returns The frequency.
910
910
 * @param   pVM     VM handle.
911
911
 */
912
912
VMM_INT_DECL(uint64_t) TMVirtualGetFreq(PVM pVM)
963
963
 * @returns nanoseconds.
964
964
 * @param   pVM             The VM handle.
965
965
 * @param   u64VirtualTicks The virtual ticks to convert.
966
 
 * @remark  There could be rounding errors here. We just do a simple integere divide
 
966
 * @remark  There could be rounding errors here. We just do a simple integer divide
967
967
 *          without any adjustments.
968
968
 */
969
969
VMM_INT_DECL(uint64_t) TMVirtualToNano(PVM pVM, uint64_t u64VirtualTicks)
979
979
 * @returns microseconds.
980
980
 * @param   pVM             The VM handle.
981
981
 * @param   u64VirtualTicks The virtual ticks to convert.
982
 
 * @remark  There could be rounding errors here. We just do a simple integere divide
 
982
 * @remark  There could be rounding errors here. We just do a simple integer divide
983
983
 *          without any adjustments.
984
984
 */
985
985
VMM_INT_DECL(uint64_t) TMVirtualToMicro(PVM pVM, uint64_t u64VirtualTicks)
995
995
 * @returns milliseconds.
996
996
 * @param   pVM             The VM handle.
997
997
 * @param   u64VirtualTicks The virtual ticks to convert.
998
 
 * @remark  There could be rounding errors here. We just do a simple integere divide
 
998
 * @remark  There could be rounding errors here. We just do a simple integer divide
999
999
 *          without any adjustments.
1000
1000
 */
1001
1001
VMM_INT_DECL(uint64_t) TMVirtualToMilli(PVM pVM, uint64_t u64VirtualTicks)
1002
1002
{
1003
 
        AssertCompile(TMCLOCK_FREQ_VIRTUAL == 1000000000);
 
1003
    AssertCompile(TMCLOCK_FREQ_VIRTUAL == 1000000000);
1004
1004
    return u64VirtualTicks / 1000000;
1005
1005
}
1006
1006