VirtualBox

Changeset 9950 in vbox


Ignore:
Timestamp:
Jun 26, 2008 11:56:57 AM (16 years ago)
Author:
vboxsync
Message:

Corrected NtQueryTimerResolution (max resolution == the lower number), print the results in ns instead of 100ns units.

Location:
trunk/src/VBox/Runtime
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Runtime/r3/win/timer-win.cpp

    r9444 r9950  
    7878/* from sysinternals. */
    7979NTSYSAPI LONG NTAPI NtSetTimerResolution(IN ULONG DesiredResolution, IN BOOLEAN SetResolution, OUT PULONG CurrentResolution);
    80 NTSYSAPI LONG NTAPI NtQueryTimerResolution(OUT PULONG MinimumResolution, OUT PULONG MaximumResolution, OUT PULONG CurrentResolution);
     80NTSYSAPI LONG NTAPI NtQueryTimerResolution(OUT PULONG MaximumResolution, OUT PULONG MinimumResolution, OUT PULONG CurrentResolution);
    8181__END_DECLS
    8282
     
    290290     * we start the timer.
    291291     */
    292     ULONG Min = ~0;
    293     ULONG Max = ~0;
    294     ULONG Cur = ~0;
    295     NtQueryTimerResolution(&Min, &Max, &Cur);
    296     Log(("NtQueryTimerResolution -> Min=%lu Max=%lu Cur=%lu (100ns)\n", Min, Max, Cur));
    297     if (Cur > Max && Cur > 10000 /* = 1ms */)
    298     {
    299         if (NtSetTimerResolution(10000, TRUE, &Cur) >= 0)
     292    ULONG ulMax = ~0;
     293    ULONG ulMin = ~0;
     294    ULONG ulCur = ~0;
     295    NtQueryTimerResolution(&ulMax, &ulMin, &ulCur);
     296    Log(("NtQueryTimerResolution -> ulMax=%lu00ns ulMin=%lu00ns ulCur=%lu00ns\n", ulMax, ulMin, ulCur));
     297    if (ulCur > ulMin && ulCur > 10000 /* = 1ms */)
     298    {
     299        if (NtSetTimerResolution(10000, TRUE, &ulCur) >= 0)
    300300            Log(("Changed timer resolution to 1ms.\n"));
    301         else if (NtSetTimerResolution(20000, TRUE, &Cur) >= 0)
     301        else if (NtSetTimerResolution(20000, TRUE, &ulCur) >= 0)
    302302            Log(("Changed timer resolution to 2ms.\n"));
    303         else if (NtSetTimerResolution(40000, TRUE, &Cur) >= 0)
     303        else if (NtSetTimerResolution(40000, TRUE, &ulCur) >= 0)
    304304            Log(("Changed timer resolution to 4ms.\n"));
    305         else if (Max <= 50000 && NtSetTimerResolution(Max, TRUE, &Cur) >= 0)
    306             Log(("Changed timer resolution to %lu *100ns.\n", Max));
     305        else if (ulMin <= 50000 && NtSetTimerResolution(ulMin, TRUE, &ulCur) >= 0)
     306            Log(("Changed timer resolution to %lu *100ns.\n", ulMin));
    307307        else
    308308        {
     
    330330        if (pTimer->TimerId)
    331331        {
    332             ULONG Min = ~0;
    333             ULONG Max = ~0;
    334             ULONG Cur = ~0;
    335             NtQueryTimerResolution(&Min, &Max, &Cur);
    336             Log(("NtQueryTimerResolution -> Min=%lu Max=%lu Cur=%lu (100ns)\n", Min, Max, Cur));
     332            ULONG ulMax = ~0;
     333            ULONG ulMin = ~0;
     334            ULONG ulCur = ~0;
     335            NtQueryTimerResolution(&ulMax, &ulMin, &ulCur);
     336            Log(("NtQueryTimerResolution -> ulMax=%lu00ns ulMin=%lu00ns ulCur=%lu00ns\n", ulMax, ulMin, ulCur));
    337337
    338338            *ppTimer = pTimer;
  • trunk/src/VBox/Runtime/testcase/ntGetTimerResolution.cpp

    r8245 r9950  
    3939extern "C" {
    4040/* from sysinternals. */
    41 NTSYSAPI LONG NTAPI NtQueryTimerResolution(OUT PULONG MinimumResolution, OUT PULONG MaximumResolution, OUT PULONG CurrentResolution);
     41NTSYSAPI LONG NTAPI NtQueryTimerResolution(OUT PULONG MaximumResolution, OUT PULONG MinimumResolution, OUT PULONG CurrentResolution);
    4242}
    4343
     
    4848    ULONG Max = ~0;
    4949    ULONG Cur = ~0;
    50     NtQueryTimerResolution(&Min, &Max, &Cur);
    51     printf("NtQueryTimerResolution -> Min=%lu Max=%lu Cur=%lu (100ns)\n", Min, Max, Cur);
     50    NtQueryTimerResolution(&Max, &Min, &Cur);
     51    printf("NtQueryTimerResolution -> Max=%lu00ns Min=%lu00ns Cur=%lu00ns\n", Min, Max, Cur);
    5252
    5353#if 0
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