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:
@@ -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);
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -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 *);
|
||||
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user