summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRichard Braun <rbraun@sceen.net>2017-06-24 22:01:09 +0200
committerRichard Braun <rbraun@sceen.net>2017-06-24 22:01:09 +0200
commit7fc9d340e5ff385846c0c77fd24877c1b208a3bb (patch)
tree9cc4eaaf00e59bef6e5a696ae98f027de1064be7
parent5127024f429da92ffdb93ba3cc0af367bc26f703 (diff)
Move the HZ macro to the kern/thread module
-rw-r--r--arch/x86/machine/lapic.c4
-rw-r--r--arch/x86/machine/param.h8
-rw-r--r--kern/thread.c8
-rw-r--r--kern/thread.h8
4 files changed, 14 insertions, 14 deletions
diff --git a/arch/x86/machine/lapic.c b/arch/x86/machine/lapic.c
index c20eec7d..e513688c 100644
--- a/arch/x86/machine/lapic.c
+++ b/arch/x86/machine/lapic.c
@@ -212,7 +212,7 @@ lapic_compute_freq(void)
lapic_bus_freq = (c1 - c2) * (1000000 / LAPIC_TIMER_CAL_DELAY);
log_info("lapic: bus frequency: %u.%02u MHz", lapic_bus_freq / 1000000,
lapic_bus_freq % 1000000);
- lapic_write(&lapic_map->timer_icr, lapic_bus_freq / HZ);
+ lapic_write(&lapic_map->timer_icr, lapic_bus_freq / THREAD_TICK_FREQ);
lapic_write(&lapic_map->svr, 0);
}
@@ -239,7 +239,7 @@ lapic_setup_registers(void)
lapic_write(&lapic_map->lvt_lint1, LAPIC_LVT_MASK_INTR);
lapic_write(&lapic_map->lvt_error, TRAP_LAPIC_ERROR);
lapic_write(&lapic_map->timer_dcr, LAPIC_TIMER_DCR_DIV1);
- lapic_write(&lapic_map->timer_icr, lapic_bus_freq / HZ);
+ lapic_write(&lapic_map->timer_icr, lapic_bus_freq / THREAD_TICK_FREQ);
}
void __init
diff --git a/arch/x86/machine/param.h b/arch/x86/machine/param.h
index f9abaa40..db60c8fd 100644
--- a/arch/x86/machine/param.h
+++ b/arch/x86/machine/param.h
@@ -25,14 +25,6 @@
#include <kern/macros.h>
/*
- * System timer frequency.
- *
- * The selected value of 200 translates to a period of 5ms, small enough to
- * provide low latency, and is practical as both a dividend and divisor.
- */
-#define HZ 200
-
-/*
* 4 KiB pages.
*/
#define PAGE_SHIFT 12
diff --git a/kern/thread.c b/kern/thread.c
index 785640cb..cd0717c4 100644
--- a/kern/thread.c
+++ b/kern/thread.c
@@ -54,7 +54,7 @@
*
* A few terms are used by both papers with slightly different meanings. Here
* are the definitions used in this implementation :
- * - The time unit is the system timer period (1 / HZ)
+ * - The time unit is the system timer period (1 / tick frequency)
* - Work is the amount of execution time units consumed
* - Weight is the amount of execution time units allocated
* - A round is the shortest period during which all threads in a run queue
@@ -159,7 +159,7 @@
/*
* Default time slice for real-time round-robin scheduling.
*/
-#define THREAD_DEFAULT_RR_TIME_SLICE (HZ / 10)
+#define THREAD_DEFAULT_RR_TIME_SLICE (THREAD_TICK_FREQ / 10)
/*
* Maximum number of threads which can be pulled from a remote run queue
@@ -170,7 +170,7 @@
/*
* Delay (in ticks) between two balance attempts when a run queue is idle.
*/
-#define THREAD_IDLE_BALANCE_TICKS (HZ / 2)
+#define THREAD_IDLE_BALANCE_TICKS (THREAD_TICK_FREQ / 2)
/*
* Run queue properties for real-time threads.
@@ -190,7 +190,7 @@ struct thread_rt_runq {
/*
* Round slice base unit for fair-scheduling threads.
*/
-#define THREAD_FS_ROUND_SLICE_BASE (HZ / 10)
+#define THREAD_FS_ROUND_SLICE_BASE (THREAD_TICK_FREQ / 10)
/*
* Group of threads sharing the same weight.
diff --git a/kern/thread.h b/kern/thread.h
index f41daefb..24e3c677 100644
--- a/kern/thread.h
+++ b/kern/thread.h
@@ -47,6 +47,14 @@
#include <machine/tcb.h>
/*
+ * Scheduler tick frequency.
+ *
+ * The selected value of 200 translates to a period of 5ms, small enough to
+ * provide low latency, and is practical as both a dividend and divisor.
+ */
+#define THREAD_TICK_FREQ 200
+
+/*
* Thread structure.
*/
struct thread;