diff options
Diffstat (limited to 'src/common/x64/native_clock.cpp')
| -rw-r--r-- | src/common/x64/native_clock.cpp | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/src/common/x64/native_clock.cpp b/src/common/x64/native_clock.cpp index f1bc60fd2..424b39b1f 100644 --- a/src/common/x64/native_clock.cpp +++ b/src/common/x64/native_clock.cpp | |||
| @@ -3,6 +3,7 @@ | |||
| 3 | // Refer to the license.txt file included. | 3 | // Refer to the license.txt file included. |
| 4 | 4 | ||
| 5 | #include <chrono> | 5 | #include <chrono> |
| 6 | #include <mutex> | ||
| 6 | #include <thread> | 7 | #include <thread> |
| 7 | 8 | ||
| 8 | #ifdef _MSC_VER | 9 | #ifdef _MSC_VER |
| @@ -52,7 +53,7 @@ NativeClock::NativeClock(u64 emulated_cpu_frequency, u64 emulated_clock_frequenc | |||
| 52 | } | 53 | } |
| 53 | 54 | ||
| 54 | u64 NativeClock::GetRTSC() { | 55 | u64 NativeClock::GetRTSC() { |
| 55 | rtsc_serialize.lock(); | 56 | std::scoped_lock scope{rtsc_serialize}; |
| 56 | _mm_mfence(); | 57 | _mm_mfence(); |
| 57 | const u64 current_measure = __rdtsc(); | 58 | const u64 current_measure = __rdtsc(); |
| 58 | u64 diff = current_measure - last_measure; | 59 | u64 diff = current_measure - last_measure; |
| @@ -61,7 +62,6 @@ u64 NativeClock::GetRTSC() { | |||
| 61 | last_measure = current_measure; | 62 | last_measure = current_measure; |
| 62 | } | 63 | } |
| 63 | accumulated_ticks += diff; | 64 | accumulated_ticks += diff; |
| 64 | rtsc_serialize.unlock(); | ||
| 65 | /// The clock cannot be more precise than the guest timer, remove the lower bits | 65 | /// The clock cannot be more precise than the guest timer, remove the lower bits |
| 66 | return accumulated_ticks & inaccuracy_mask; | 66 | return accumulated_ticks & inaccuracy_mask; |
| 67 | } | 67 | } |