Refined cv_factor calculation.

Also set TIMER_CLKNUM_HZ to its correct value.


git-svn-id: file:///srv/svn/repos/haiku/trunk/current@418 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
notion
2002-07-24 12:39:31 +00:00
parent 7a89b5cb9e
commit 719e338bae
+10 -8
View File
@@ -497,7 +497,7 @@ sleep(uint64 time)
_v; \ _v; \
}) })
#define TIMER_CLKNUM_HZ 1193167 #define TIMER_CLKNUM_HZ (14318180/12)
static void static void
calculate_cpu_conversion_factor(void) calculate_cpu_conversion_factor(void)
@@ -619,10 +619,13 @@ not_so_quick_sample:
* So the final expression is: * So the final expression is:
* *
* ((C*x0)/p3)<<k + (((C*x0)%p3)<<k)/p3 + (C*x1)/p3 * ((C*x0)/p3)<<k + (((C*x0)%p3)<<k)/p3 + (C*x1)/p3
* */
* Just to make things fancier we choose k based on the input /*
* parameters (we use log2(expired)/3.) * To get the highest accuracy with this method
* * x0 should have the 12 most significant bits of expired
* to minimize the error upon <<k.
*/
/*
* Of course, you are not expected to understand any of this. * Of course, you are not expected to understand any of this.
*/ */
{ {
@@ -635,11 +638,10 @@ not_so_quick_sample:
/* first calculate k*/ /* first calculate k*/
k = 0; k = 0;
for (i = 0; i< 32; i++) { for (i = 12; i < 16; i++) {
if (expired & (1<<i)) if (expired & (1<<i))
k = i; k = i - 11;
} }
k /= 3;
C = 1000000ULL << 32; C = 1000000ULL << 32;
x0 = expired >> k; x0 = expired >> k;