From 96191076161efc4f29ae1efdcd636a7dafe9fb8e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michael=20M=C3=B6ller?= Date: Fri, 1 Oct 2010 19:01:09 +0000 Subject: [PATCH] Fixed the initialization of the TSC estimating code. --- Hardware/CPU/AMD10CPU.cs | 5 ----- Hardware/CPU/GenericCPU.cs | 24 +++++++++++++++++------- Properties/AssemblyVersion.cs | 4 ++-- 3 files changed, 19 insertions(+), 14 deletions(-) diff --git a/Hardware/CPU/AMD10CPU.cs b/Hardware/CPU/AMD10CPU.cs index 689f5f5..875bf8f 100644 --- a/Hardware/CPU/AMD10CPU.cs +++ b/Hardware/CPU/AMD10CPU.cs @@ -64,8 +64,6 @@ namespace OpenHardwareMonitor.Hardware.CPU { private double timeStampCounterMultiplier; - private StringBuilder debug = new StringBuilder(); - public AMD10CPU(int processorIndex, CPUID[][] cpuid, ISettings settings) : base(processorIndex, cpuid, settings) { @@ -180,9 +178,6 @@ namespace OpenHardwareMonitor.Hardware.CPU { CultureInfo.InvariantCulture)); r.AppendLine(); - r.Append(debug); - r.AppendLine(); - return r.ToString(); } diff --git a/Hardware/CPU/GenericCPU.cs b/Hardware/CPU/GenericCPU.cs index 87ef70a..fcf27db 100644 --- a/Hardware/CPU/GenericCPU.cs +++ b/Hardware/CPU/GenericCPU.cs @@ -119,14 +119,24 @@ namespace OpenHardwareMonitor.Hardware.CPU { ActivateSensor(totalLoad); } - if (hasTimeStampCounter) - estimatedTimeStampCounterFrequency = EstimateTimeStampCounterFrequency(); - else - estimatedTimeStampCounterFrequency = 0; - timeStampCounterFrequency = estimatedTimeStampCounterFrequency; + if (hasTimeStampCounter) { + estimatedTimeStampCounterFrequency = + EstimateTimeStampCounterFrequency(); + + // set initial values + uint lsb, msb; + WinRing0.RdtscTx(out lsb, out msb, (UIntPtr)1); + lastTime = Stopwatch.GetTimestamp(); + lastTimeStampCount = ((ulong)msb << 32) | lsb; - lastTimeStampCount = 0; - lastTime = 0; + } else { + estimatedTimeStampCounterFrequency = 0; + + lastTime = 0; + lastTimeStampCount = 0; + } + + timeStampCounterFrequency = estimatedTimeStampCounterFrequency; } private static double EstimateTimeStampCounterFrequency() { diff --git a/Properties/AssemblyVersion.cs b/Properties/AssemblyVersion.cs index ecfbc5c..f8e8e27 100644 --- a/Properties/AssemblyVersion.cs +++ b/Properties/AssemblyVersion.cs @@ -37,5 +37,5 @@ using System.Reflection; -[assembly: AssemblyVersion("0.1.37.23")] -[assembly: AssemblyInformationalVersion("0.1.37.23 Alpha")] \ No newline at end of file +[assembly: AssemblyVersion("0.1.37.24")] +[assembly: AssemblyInformationalVersion("0.1.37.24 Alpha")] \ No newline at end of file