Tick at 1000Hz not 1MHz.

Our FreeBSD networking code defined hz to 1MHz and 1 tick = 1 / hz,
but the clock code ticked 1 tick at 1000Hz.

This caused all calculations that are done on ticks, autonegotiation
and wlan scanning to be done very often as FreeBSD uses 1000 Hz
(100Hz for ARM). Defaults for autonegotiation is 5 and 17 ticks.

(Another interesting thing is that callouts are using 8% cpu...)
This commit is contained in:
Fredrik Holmqvist
2012-07-16 13:52:08 +02:00
parent 3bbf781c1a
commit 73fc635b3d
5 changed files with 18 additions and 33 deletions
@@ -12,9 +12,6 @@ extern "C" {
#include "Condvar.h" #include "Condvar.h"
#define ticks_to_usecs(t) (1000000*((bigtime_t)t) / hz)
void void
conditionInit(struct cv* variable, const char* description) conditionInit(struct cv* variable, const char* description)
{ {
+1 -1
View File
@@ -116,7 +116,7 @@ init_callout(void)
} }
sThread = spawn_kernel_thread(callout_thread, "fbsd callout", sThread = spawn_kernel_thread(callout_thread, "fbsd callout",
B_URGENT_DISPLAY_PRIORITY, NULL); B_DISPLAY_PRIORITY, NULL);
if (sThread < 0) { if (sThread < 0) {
status = sThread; status = sThread;
goto err2; goto err2;
+4 -16
View File
@@ -5,10 +5,7 @@
#include "device.h" #include "device.h"
#include "kernel.h"
#define CONVERT_HZ_TO_USECS(hertz) (1000000LL / (hertz))
#define FREEBSD_CLOCK_FREQUENCY_IN_HZ 1000
int ticks; int ticks;
@@ -27,24 +24,15 @@ hardClock(timer* hardClockTimer)
/*! /*!
* Initialization of the hardclock timer. * Initialization of the hardclock timer which ticks according to hz defined in
* * compat/sys/kernel.h.
* Note: We are not using the FreeBSD variable hz as the invocation frequency
* as it is the case in FreeBSD's hardclock function. This is due to lower
* system load. The hz (see compat/sys/kernel.h) variable in the compat layer is
* set to 1000000 Hz, whereas it is usually set to 1000 Hz for FreeBSD.
*/ */
status_t status_t
init_hard_clock() init_hard_clock()
{ {
status_t status;
ticks = 0; ticks = 0;
status = add_timer(&sHardClockTimer, hardClock, return add_timer(&sHardClockTimer, hardClock, ticks_to_usecs(1),
CONVERT_HZ_TO_USECS(FREEBSD_CLOCK_FREQUENCY_IN_HZ),
B_PERIODIC_TIMER); B_PERIODIC_TIMER);
return status;
} }
@@ -17,18 +17,18 @@
/* /*
* *
* In FreeBSD hz holds the count of how often the thread scheduler is invoked * The rate at which FreeBSD can generate callouts (kind of timeout mechanism).
* per second. Moreover this is the rate at which FreeBSD can generate callouts * For FreeBSD 8 this is typically 1000 times per second (100 for ARM).
* (kind of timeout mechanism). * This value is defined in a file called subr_param.c
* For FreeBSD 8 this is typically 1000 times per second. This value is defined
* in a file called subr_param.c
* *
* For Haiku this value is much higher, due to using another timeout scheduling * WHile Haiku can have a much higher granularity, it is not a good idea to have
* mechanism, which has a resolution of 1 MHz. So hz for Haiku is set to * this since FreeBSD tries to do certain tasks based on ticks, for instance
* 1000000. Suffixing LL prevents integer overflows during calculations. * autonegotiation and wlan scanning.
* Suffixing LL prevents integer overflows during calculations.
* as it defines a long long constant.*/ * as it defines a long long constant.*/
#define hz 1000000LL #define hz 1000LL
#define ticks_to_usecs(t) (1000000*((bigtime_t)t) / hz)
typedef void (*system_init_func_t)(void *); typedef void (*system_init_func_t)(void *);
@@ -12,7 +12,7 @@
#include <sys/types.h> #include <sys/types.h>
#define time_uptime system_time() / 1000000 #define time_uptime (system_time() / 1000000)
int ppsratecheck(struct timeval*, int*, int); int ppsratecheck(struct timeval*, int*, int);