diff --git a/src/libs/compat/freebsd_network/Condvar.cpp b/src/libs/compat/freebsd_network/Condvar.cpp index c1343b3ce2..74499ef0cb 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 f062da5824..1541580500 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 aa3612c745..91a095429d 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 6c8c545f7d..615b9f760d 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 1bbabb743a..4b061e3ad4 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 -#define time_uptime system_time() / 1000000 +#define time_uptime (system_time() / 1000000) int ppsratecheck(struct timeval*, int*, int);