- Timestamp:
- Oct 24, 2007 2:18:28 AM (17 years ago)
- svn:sync-xref-src-repo-rev:
- 25635
- Location:
- trunk
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/include/iprt/time.h
r5456 r5461 726 726 /** Where the previous timestamp is stored. 727 727 * This is maintained to ensure that time doesn't go backwards or anything. */ 728 uint64_t volatile u64Prev; 729 /** Number of 1ns steps because of overshooting the period. */ 730 uint32_t c1nsSteps; 731 /** The number of times the interval expired (overflow). */ 732 uint32_t cExpired; 733 /** Number of "bad" previous values. */ 734 uint32_t cBadPrev; 735 /** The number of update races. */ 736 uint32_t cUpdateRaces; 728 uint64_t volatile *pu64Prev; 737 729 738 730 /** … … 753 745 */ 754 746 DECLCALLBACKMEMBER(uint64_t, pfnRediscover)(PRTTIMENANOTSDATA pData); 747 748 /** Number of 1ns steps because of overshooting the period. */ 749 uint32_t c1nsSteps; 750 /** The number of times the interval expired (overflow). */ 751 uint32_t cExpired; 752 /** Number of "bad" previous values. */ 753 uint32_t cBadPrev; 754 /** The number of update races. */ 755 uint32_t cUpdateRaces; 755 756 } RTTIMENANOTSDATA; 757 758 /** 759 * The Ring-3 layout of the RTTIMENANOTSDATA structure. 760 */ 761 typedef struct RTTIMENANOTSDATAR3 762 { 763 R3PTRTYPE(uint64_t volatile *) pu64Prev; 764 DECLR3CALLBACKMEMBER(void, pfnBad,(PRTTIMENANOTSDATA pData, uint64_t u64NanoTS, uint64_t u64DeltaPrev, uint64_t u64PrevNanoTS)); 765 DECLR3CALLBACKMEMBER(uint64_t, pfnRediscover,(PRTTIMENANOTSDATA pData)); 766 uint32_t c1nsSteps; 767 uint32_t cExpired; 768 uint32_t cBadPrev; 769 uint32_t cUpdateRaces; 770 } RTTIMENANOTSDATAR3; 771 772 /** 773 * The Ring-3 layout of the RTTIMENANOTSDATA structure. 774 */ 775 typedef struct RTTIMENANOTSDATAR0 776 { 777 R0PTRTYPE(uint64_t volatile *) pu64Prev; 778 DECLR0CALLBACKMEMBER(void, pfnBad,(PRTTIMENANOTSDATA pData, uint64_t u64NanoTS, uint64_t u64DeltaPrev, uint64_t u64PrevNanoTS)); 779 DECLR0CALLBACKMEMBER(uint64_t, pfnRediscover,(PRTTIMENANOTSDATA pData)); 780 uint32_t c1nsSteps; 781 uint32_t cExpired; 782 uint32_t cBadPrev; 783 uint32_t cUpdateRaces; 784 } RTTIMENANOTSDATAR0; 785 786 /** 787 * The GC layout of the RTTIMENANOTSDATA structure. 788 */ 789 typedef struct RTTIMENANOTSDATAGC 790 { 791 GCPTRTYPE(uint64_t volatile *) pu64Prev; 792 DECLGCCALLBACKMEMBER(void, pfnBad,(PRTTIMENANOTSDATA pData, uint64_t u64NanoTS, uint64_t u64DeltaPrev, uint64_t u64PrevNanoTS)); 793 DECLGCCALLBACKMEMBER(uint64_t, pfnRediscover,(PRTTIMENANOTSDATA pData)); 794 uint32_t c1nsSteps; 795 uint32_t cExpired; 796 uint32_t cBadPrev; 797 uint32_t cUpdateRaces; 798 } RTTIMENANOTSDATAGC; 756 799 757 800 /** Internal RTTimeNanoTS worker (assembly). */ -
trunk/src/VBox/Runtime/Makefile.kmk
r5459 r5461 209 209 r3/tcp.cpp 210 210 211 #if1of ($(BUILD_TARGET_ARCH),amd64 x86)212 #RuntimeR3_SOURCES += common/time/timesupA.asm213 #else211 if1of ($(BUILD_TARGET_ARCH),amd64 x86) 212 RuntimeR3_SOURCES += common/time/timesupA.asm 213 else 214 214 RuntimeR3_SOURCES += common/time/timesupref.cpp 215 #endif215 endif 216 216 217 217 ifdef IPRT_WITH_KLDR … … 680 680 VBox/strformat-vbox.cpp 681 681 682 #if1of ($(BUILD_TARGET_ARCH),amd64 x86)683 #RuntimeR0_SOURCES += common/time/timesupA.asm684 #else682 if1of ($(BUILD_TARGET_ARCH),amd64 x86) 683 RuntimeR0_SOURCES += common/time/timesupA.asm 684 else 685 685 RuntimeR0_SOURCES += common/time/timesupref.cpp 686 #endif686 endif 687 687 688 688 RuntimeR0_SOURCES.win.amd64 = $(RuntimeWin64ASM_SOURCES) … … 1010 1010 VBox/strformat-vbox.cpp \ 1011 1011 1012 #if1of ($(BUILD_TARGET_ARCH),amd64 x86)1013 #RuntimeGC_SOURCES += common/time/timesupA.asm1014 #else1012 if1of ($(BUILD_TARGET_ARCH),amd64 x86) 1013 RuntimeGC_SOURCES += common/time/timesupA.asm 1014 else 1015 1015 RuntimeGC_SOURCES += common/time/timesupref.cpp 1016 #endif1016 endif 1017 1017 1018 1018 ifeq ($(VBOX_LDR_FMT32),lx) -
trunk/src/VBox/Runtime/common/time/timesup.cpp
r5456 r5461 47 47 *******************************************************************************/ 48 48 #ifndef IN_GUEST 49 /** The previous timestamp value returned by RTTimeNanoTS. */ 50 static uint64_t g_TimeNanoTSPrev = 0; 51 49 52 /** The RTTimeNanoTS data structure that's passed down to the worker functions. */ 50 53 static RTTIMENANOTSDATA g_TimeNanoTSData = 51 54 { 52 /* .u64Prev = */ 0, 55 /* .pu64Prev = */ &g_TimeNanoTSPrev, 56 /* .pfnBad = */ rtTimeNanoTSInternalBitch, 57 /* .pfnRediscover = */ rtTimeNanoTSInternalRediscover, 53 58 /* .c1nsSteps = */ 0, 54 59 /* .cExpired = */ 0, 55 60 /* .cBadPrev = */ 0, 56 /* .cUpdateRaces = */ 0, 57 /* .pfnBad = */ rtTimeNanoTSInternalBitch, 58 /* .pfnRediscover = */ rtTimeNanoTSInternalRediscover 61 /* .cUpdateRaces = */ 0 59 62 }; 60 63 -
trunk/src/VBox/Runtime/common/time/timesupA.asm
r5457 r5461 25 25 ;; Keep this in sync with iprt/time.h. 26 26 struc RTTIMENANOTSDATA 27 .u64Prev resq 1 27 .pu64Prev RTCCPTR_RES 1 28 .pfnBad RTCCPTR_RES 1 29 .pfnRediscover RTCCPTR_RES 1 28 30 .c1nsSteps resd 1 29 31 .cExpired resd 1 30 32 .cBadPrev resd 1 31 33 .cUpdateRaces resd 1 32 .pfnBad RTCCPTR_RES 133 .pfnRediscover RTCCPTR_RES 134 34 endstruc 35 35 -
trunk/src/VBox/Runtime/common/time/timesupA.mac
r5460 r5461 104 104 ; RDTSC result, we try to make sure it has completed as well. 105 105 mov esi, pData 106 mov esi, [esi + RTTIMENANOTSDATA.pu64Prev] 106 107 mov ebx, eax 107 108 mov ecx, edx 108 lock cmpxchg8b [esi + RTTIMENANOTSDATA.u64Prev]109 lock cmpxchg8b [esi] 109 110 mov u64PrevNanoTS, eax 110 111 mov u64PrevNanoTS_Hi, edx … … 191 192 mov ecx, edx 192 193 mov esi, pData 194 mov esi, [esi + RTTIMENANOTSDATA.pu64Prev] 193 195 mov eax, u64PrevNanoTS 194 196 mov edx, u64PrevNanoTS_Hi 195 lock cmpxchg8b [esi + RTTIMENANOTSDATA.u64Prev]197 lock cmpxchg8b [esi] 196 198 jnz .UpdateFailed 197 199 … … 498 500 mov u32UpdateIntervalTSC, [pGipCPU + SUPGIPCPU.u32UpdateIntervalTSC] 499 501 rdtsc 500 mov u64PrevNanoTS, [pData + RTTIMENANOTSDATA.u64Prev] 502 mov u64PrevNanoTS, [pData + RTTIMENANOTSDATA.pu64Prev] 503 mov u64PrevNanoTS, [u64PrevNanoTS] 501 504 shl rdx, 32 502 505 %ifdef u64SavedRetNanoTS ; doing this here saves a tick or so. … … 574 577 .Update: 575 578 ; if (RT_LIKELY(ASMAtomicCmpXchgU64(&pData->u64Prev, u64RetNanoTS, u64PrevNanoTS))) 579 mov rbx, [pData + RTTIMENANOTSDATA.pu64Prev] 576 580 mov rcx, rax 577 581 mov rax, u64PrevNanoTS 578 lock cmpxchg [ pData + RTTIMENANOTSDATA.u64Prev], rcx582 lock cmpxchg [rbx], rcx 579 583 jnz .UpdateFailed 580 584 … … 691 695 lock inc dword [pData + RTTIMENANOTSDATA.cUpdateRaces] 692 696 ; for (i = 0; i < 10; i++) 693 mov e bx, 10697 mov edx, 10 694 698 .UpdateLoop: 695 699 ; if (u64PrevNanoTS >= u64RetNanoTS) … … 699 703 .UpdateLoopLess: 700 704 ; retry 701 lock cmpxchg [ pData + RTTIMENANOTSDATA.u64Prev], rcx705 lock cmpxchg [rbx], rcx 702 706 jz .Updated 703 dec e bx707 dec edx 704 708 jnz .UpdateLoop 705 709 jmp .Updated -
trunk/src/VBox/Runtime/common/time/timesupref.h
r5456 r5461 72 72 u32NanoTSFactor0 = pGip->u32UpdateIntervalNS; 73 73 u64Delta = ASMReadTSC(); 74 u64PrevNanoTS = ASMAtomicReadU64( &pData->u64Prev);74 u64PrevNanoTS = ASMAtomicReadU64(pData->pu64Prev); 75 75 76 76 #ifdef NEED_TRANSACTION_ID … … 142 142 } 143 143 144 if (RT_LIKELY(ASMAtomicCmpXchgU64( &pData->u64Prev, u64NanoTS, u64PrevNanoTS)))144 if (RT_LIKELY(ASMAtomicCmpXchgU64(pData->pu64Prev, u64NanoTS, u64PrevNanoTS))) 145 145 { 146 146 /* … … 154 154 for (int cTries = 25;;) 155 155 { 156 u64PrevNanoTS = ASMAtomicReadU64( &pData->u64Prev);156 u64PrevNanoTS = ASMAtomicReadU64(pData->pu64Prev); 157 157 if (u64PrevNanoTS >= u64NanoTS) 158 158 break; 159 if (ASMAtomicCmpXchgU64( &pData->u64Prev, u64NanoTS, u64PrevNanoTS))159 if (ASMAtomicCmpXchgU64(pData->pu64Prev, u64NanoTS, u64PrevNanoTS)) 160 160 break; 161 161 AssertBreak(--cTries <= 0, );
Note:
See TracChangeset
for help on using the changeset viewer.