hrev44347 adds 1 changeset to branch 'master' old head: 3bbf781c1a27f5c0e8d4f3c632908174ed1f6ede new head: 73fc635b3d87970ed7843eacd0ac7a5ffcac0e9b ---------------------------------------------------------------------------- 73fc635: 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...) [ Fredrik Holmqvist <fredrik.holmqvist@xxxxxxxxx> ] ---------------------------------------------------------------------------- Revision: hrev44347 Commit: 73fc635b3d87970ed7843eacd0ac7a5ffcac0e9b URL: http://cgit.haiku-os.org/haiku/commit/?id=73fc635 Author: Fredrik Holmqvist <fredrik.holmqvist@xxxxxxxxx> Date: Mon Jul 16 11:41:08 2012 UTC ---------------------------------------------------------------------------- 5 files changed, 18 insertions(+), 33 deletions(-) src/libs/compat/freebsd_network/Condvar.cpp | 5 +--- src/libs/compat/freebsd_network/callout.cpp | 6 ++--- src/libs/compat/freebsd_network/clock.c | 20 ++++------------ .../compat/freebsd_network/compat/sys/kernel.h | 18 +++++++------- src/libs/compat/freebsd_network/compat/sys/time.h | 2 +- ---------------------------------------------------------------------------- diff --git a/src/libs/compat/freebsd_network/Condvar.cpp b/src/libs/compat/freebsd_network/Condvar.cpp index c1343b3..74499ef 100644 --- a/src/libs/compat/freebsd_network/Condvar.cpp +++ b/src/libs/compat/freebsd_network/Condvar.cpp @@ -12,9 +12,6 @@ extern "C" { #include "Condvar.h" -#define ticks_to_usecs(t) (1000000*((bigtime_t)t) / hz) - - void conditionInit(struct cv* variable, const char* description) { @@ -23,7 +20,7 @@ conditionInit(struct cv* variable, const char* description) void -conditionPublish(struct cv* variable, const void* waitChannel, +conditionPublish(struct cv* variable, const void* waitChannel, const char* description) { variable->condition.Publish(waitChannel, description); diff --git a/src/libs/compat/freebsd_network/callout.cpp b/src/libs/compat/freebsd_network/callout.cpp index f062da5..1541580 100644 --- a/src/libs/compat/freebsd_network/callout.cpp +++ b/src/libs/compat/freebsd_network/callout.cpp @@ -62,9 +62,9 @@ callout_thread(void* /*data*/) if (mutex != NULL) mtx_lock(mutex); - + c->c_func(c->c_arg); - + if (mutex != NULL) mtx_unlock(mutex); @@ -116,7 +116,7 @@ init_callout(void) } sThread = spawn_kernel_thread(callout_thread, "fbsd callout", - B_URGENT_DISPLAY_PRIORITY, NULL); + B_DISPLAY_PRIORITY, NULL); if (sThread < 0) { status = sThread; goto err2; diff --git a/src/libs/compat/freebsd_network/clock.c b/src/libs/compat/freebsd_network/clock.c index aa3612c..91a0954 100644 --- a/src/libs/compat/freebsd_network/clock.c +++ b/src/libs/compat/freebsd_network/clock.c @@ -5,10 +5,7 @@ #include "device.h" - - -#define CONVERT_HZ_TO_USECS(hertz) (1000000LL / (hertz)) -#define FREEBSD_CLOCK_FREQUENCY_IN_HZ 1000 +#include "kernel.h" int ticks; @@ -27,24 +24,15 @@ hardClock(timer* hardClockTimer) /*! - * Initialization of the hardclock timer. - * - * 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. + * Initialization of the hardclock timer which ticks according to hz defined in + * compat/sys/kernel.h. */ status_t init_hard_clock() { - status_t status; - ticks = 0; - status = add_timer(&sHardClockTimer, hardClock, - CONVERT_HZ_TO_USECS(FREEBSD_CLOCK_FREQUENCY_IN_HZ), + return add_timer(&sHardClockTimer, hardClock, ticks_to_usecs(1), B_PERIODIC_TIMER); - - return status; } diff --git a/src/libs/compat/freebsd_network/compat/sys/kernel.h b/src/libs/compat/freebsd_network/compat/sys/kernel.h index 6c8c545..615b9f7 100644 --- a/src/libs/compat/freebsd_network/compat/sys/kernel.h +++ b/src/libs/compat/freebsd_network/compat/sys/kernel.h @@ -17,18 +17,18 @@ /* * - * In FreeBSD hz holds the count of how often the thread scheduler is invoked - * per second. Moreover this is the rate at which FreeBSD can generate callouts - * (kind of timeout mechanism). - * For FreeBSD 8 this is typically 1000 times per second. This value is defined - * in a file called subr_param.c + * The rate at which FreeBSD can generate callouts (kind of timeout mechanism). + * For FreeBSD 8 this is typically 1000 times per second (100 for ARM). + * This value is defined in a file called subr_param.c * - * For Haiku this value is much higher, due to using another timeout scheduling - * mechanism, which has a resolution of 1 MHz. So hz for Haiku is set to - * 1000000. Suffixing LL prevents integer overflows during calculations. + * WHile Haiku can have a much higher granularity, it is not a good idea to have + * this since FreeBSD tries to do certain tasks based on ticks, for instance + * autonegotiation and wlan scanning. + * Suffixing LL prevents integer overflows during calculations. * 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 *); diff --git a/src/libs/compat/freebsd_network/compat/sys/time.h b/src/libs/compat/freebsd_network/compat/sys/time.h index 1bbabb7..4b061e3 100644 --- a/src/libs/compat/freebsd_network/compat/sys/time.h +++ b/src/libs/compat/freebsd_network/compat/sys/time.h @@ -12,7 +12,7 @@ #include <sys/types.h> -#define time_uptime system_time() / 1000000 +#define time_uptime (system_time() / 1000000) int ppsratecheck(struct timeval*, int*, int);