Hardware/CPU/GenericCPU.cs
changeset 203 ca487ba88c24
parent 201 958e9fe8afdf
child 222 ba64bb91ebe4
     1.1 --- a/Hardware/CPU/GenericCPU.cs	Thu Sep 30 20:59:21 2010 +0000
     1.2 +++ b/Hardware/CPU/GenericCPU.cs	Fri Oct 01 19:01:09 2010 +0000
     1.3 @@ -119,14 +119,24 @@
     1.4            ActivateSensor(totalLoad);
     1.5        }
     1.6  
     1.7 -      if (hasTimeStampCounter)
     1.8 -        estimatedTimeStampCounterFrequency = EstimateTimeStampCounterFrequency();
     1.9 -      else
    1.10 +      if (hasTimeStampCounter) {
    1.11 +        estimatedTimeStampCounterFrequency = 
    1.12 +          EstimateTimeStampCounterFrequency();
    1.13 +        
    1.14 +        // set initial values 
    1.15 +        uint lsb, msb;
    1.16 +        WinRing0.RdtscTx(out lsb, out msb, (UIntPtr)1);
    1.17 +        lastTime = Stopwatch.GetTimestamp();
    1.18 +        lastTimeStampCount = ((ulong)msb << 32) | lsb;
    1.19 +
    1.20 +      } else {
    1.21          estimatedTimeStampCounterFrequency = 0;
    1.22 -      timeStampCounterFrequency = estimatedTimeStampCounterFrequency;
    1.23  
    1.24 -      lastTimeStampCount = 0;
    1.25 -      lastTime = 0;
    1.26 +        lastTime = 0;
    1.27 +        lastTimeStampCount = 0;
    1.28 +      }
    1.29 +
    1.30 +      timeStampCounterFrequency = estimatedTimeStampCounterFrequency;                  
    1.31      }
    1.32  
    1.33      private static double EstimateTimeStampCounterFrequency() {