Skip to content
Snippets Groups Projects
Commit 612d028c authored by Nigel Kukard's avatar Nigel Kukard
Browse files

Changed CPU precision from float to double

parent 6951be7e
No related branches found
No related tags found
No related merge requests found
......@@ -301,10 +301,10 @@ int main (int argc, char *argv[]) {
uint64_t cpuLast = 0 ;
uint32_t cpuLimit = 0;
/* Load limit */
float loadLimit = 0.00;
double loadLimit = 0.00;
/* bucket holding how many ticks we can consume */
float tickBucket = 0;
float tickBucketMax = 0;
double tickBucket = 0;
double tickBucketMax = 0;
/* Setup default sleep period */
uint32_t sleep_us = DEFAULT_SLEEP;
......@@ -478,7 +478,7 @@ int main (int argc, char *argv[]) {
}
/* Set max tickBucket size & initialize tickBucket to that */
tickBucket = tickBucketMax = (float) HZ * ( (float) cpuLimit / (float) 100);
tickBucket = tickBucketMax = (double) HZ * ( (double) cpuLimit / (double) 100);
/* This is the main program loop */
while (loop) {
......@@ -545,7 +545,7 @@ int main (int argc, char *argv[]) {
/* Change in ticks for period */
ticks_delta = cpuNow - cpuLast;
/* Number of tickes we can eat */
ticks_allowed = ( (float) elapsed_us / (float) CLOCK_PRECISION) * tickBucketMax * ( (float) cpuLimit / 100);
ticks_allowed = ( (double) elapsed_us / (double) CLOCK_PRECISION) * HZ * ( (double) cpuLimit / 100);
/* Remove ticks we ate and add ones we allowed */
tickBucket -= ticks_delta;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment