Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
Comment: | cleanup... |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | sebres-8-5-event-perf-branch |
Files: | files | file ages | folders |
SHA1: |
059712404c09ac9f7947804b61b609e8 |
User & Date: | sebres 2017-07-03 13:32:29 |
Context
2017-07-03
| ||
13:32 | performance test cases extended check-in: 09e833e963 user: sebres tags: sebres-8-5-event-perf-branch | |
13:32 | cleanup... check-in: 059712404c user: sebres tags: sebres-8-5-event-perf-branch | |
13:32 | after at: added simple workaround for absolute timers/sleep ("after at real-time"): because we use m... check-in: 12d1d63e18 user: sebres tags: sebres-8-5-event-perf-branch | |
Changes
Changes to win/tclWinTime.c.
︙ | ︙ | |||
696 697 698 699 700 701 702 | * oscillator. */ SYSTEM_INFO systemInfo; unsigned int regs[4]; GetSystemInfo(&systemInfo); | < < < < < < < < < | 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 | * oscillator. */ SYSTEM_INFO systemInfo; unsigned int regs[4]; GetSystemInfo(&systemInfo); if (TclWinCPUID(0, regs) == TCL_OK && regs[1] == 0x756e6547 /* "Genu" */ && regs[3] == 0x49656e69 /* "ineI" */ && regs[2] == 0x6c65746e /* "ntel" */ && TclWinCPUID(1, regs) == TCL_OK && (( ((regs[0]&0x00000F00) == 0xF00) /* Pentium 4 */ || ((regs[0]&0x00000F00) == 0x600) ) /* or compatible (VM) */ && ((regs[0] & 0x0FF00000) /* Extended family (bits 20-27) */ || (regs[3] & 0x10000000))) /* Hyperthread (bit 28) */ || (((regs[1]&0x00FF0000) >> 16) >= 2 /* CPU count */ || systemInfo.dwNumberOfProcessors >= 2)) { timeInfo.perfCounterAvailable = TRUE; } else { timeInfo.perfCounterAvailable = FALSE; } } #endif /* above code is Win32 only */ /* * If the performance counter is available, initialize */ |
︙ | ︙ | |||
766 767 768 769 770 771 772 | ciEpoch = timeInfo.lastCIEpoch; memcpy(&ci, &timeInfo.lastCI, sizeof(ci)); /* * Lock on demand and hold time section locked as short as possible. */ if (InterlockedCompareExchange(&timeInfo.lastCIEpoch, ciEpoch, ciEpoch) != ciEpoch) { | < | 757 758 759 760 761 762 763 764 765 766 767 768 769 770 | ciEpoch = timeInfo.lastCIEpoch; memcpy(&ci, &timeInfo.lastCI, sizeof(ci)); /* * Lock on demand and hold time section locked as short as possible. */ if (InterlockedCompareExchange(&timeInfo.lastCIEpoch, ciEpoch, ciEpoch) != ciEpoch) { EnterCriticalSection(&timeInfo.cs); if (ciEpoch != timeInfo.lastCIEpoch) { memcpy(&ci, &timeInfo.lastCI, sizeof(ci)); ciEpoch = timeInfo.lastCIEpoch; } LeaveCriticalSection(&timeInfo.cs); } |
︙ | ︙ | |||
819 820 821 822 823 824 825 | + NativeCalc100NsOffs(ci.perfCounter, curCounter); tdiff = vt0 - sysTime; /* If we can adjust offsets (not a jump to new system time) */ if (MsToT100ns(-800) < tdiff && tdiff < MsToT100ns(800)) { /* Allow small drift if discrepancy larger as expected */ | < | 809 810 811 812 813 814 815 816 817 818 819 820 821 822 | + NativeCalc100NsOffs(ci.perfCounter, curCounter); tdiff = vt0 - sysTime; /* If we can adjust offsets (not a jump to new system time) */ if (MsToT100ns(-800) < tdiff && tdiff < MsToT100ns(800)) { /* Allow small drift if discrepancy larger as expected */ if (tdiff <= MsToT100ns(-VT_MAX_DISCREPANCY)) { vt0 += MsToT100ns(VT_MAX_DRIFT_TIME); } else if (tdiff <= MsToT100ns(-VT_MAX_DRIFT_TIME)) { vt0 -= tdiff / 2; /* small drift forwards */ } |
︙ | ︙ | |||
841 842 843 844 845 846 847 | * time-drifts). If time-reset (< 800ms) just use curent time * (avoid time correction in such case). */ if ( (lastTime = (ci.virtTimeBase + timeInfo.lastUsedTime)) && (lastTime -= vt0) > 0 /* offset to vt0 */ && lastTime < MsToT100ns(800) /* bypass time-switch (drifts only) */ ) { | < < < | 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 | * time-drifts). If time-reset (< 800ms) just use curent time * (avoid time correction in such case). */ if ( (lastTime = (ci.virtTimeBase + timeInfo.lastUsedTime)) && (lastTime -= vt0) > 0 /* offset to vt0 */ && lastTime < MsToT100ns(800) /* bypass time-switch (drifts only) */ ) { vt0 += lastTime; /* hold on the time a bit */ } /* difference for addjustment of monotonic base */ tdiff = vt0 - vt1; } else { /* * The time-jump (reset or initial), we should use system time * instead of virtual to recalibrate offsets (let the time jump). */ vt0 = sysTime; tdiff = 0; } /* * Now adjust monotonic time base, note this time should absolutely * never ticks backwards (relative the last known monotonic time). */ ci.monoTimeBase += NativeCalc100NsOffs(ci.perfCounter, curCounter); |
︙ | ︙ | |||
884 885 886 887 888 889 890 | /* base adjusted, so reset also last known offset */ timeInfo.lastUsedTime = 0; /* Update global structure lastCI with new values */ memcpy(&timeInfo.lastCI, &ci, sizeof(ci)); /* Increase epoch, to inform all other threads about new data */ InterlockedIncrement(&timeInfo.lastCIEpoch); | | < < | 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 | /* base adjusted, so reset also last known offset */ timeInfo.lastUsedTime = 0; /* Update global structure lastCI with new values */ memcpy(&timeInfo.lastCI, &ci, sizeof(ci)); /* Increase epoch, to inform all other threads about new data */ InterlockedIncrement(&timeInfo.lastCIEpoch); } /* end lock */ LeaveCriticalSection(&timeInfo.cs); } /* common info lastCI contains actual data */ calcVT: /* Calculate actual time-offset using performance counter */ |
︙ | ︙ |