summaryrefslogtreecommitdiff
path: root/kernel/drivers/pit.c
diff options
context:
space:
mode:
authorAnton Kling <anton@kling.gg>2024-03-20 18:08:57 +0100
committerAnton Kling <anton@kling.gg>2024-03-20 19:08:18 +0100
commita950021011e41b7d4fd285dde278cf9b06f89574 (patch)
tree1d88d00ac2f31d8d7c47dc84a954caea68c0b5f2 /kernel/drivers/pit.c
parent553b43d2e563dcff74d4c86904fa3737e96d7365 (diff)
MMU: Fixed massive problem in assumption of RAM layout
This caused certain addreses which where not RAM memory to be assigned to virtual addresses incorrectly. This caused a significant slowdown when running it with KVM due to constantly having to exit the VM if the OS writes to memory that is not RAM. This fix increased the performance of KVM significantly and improved TCG performance.
Diffstat (limited to 'kernel/drivers/pit.c')
-rw-r--r--kernel/drivers/pit.c12
1 files changed, 5 insertions, 7 deletions
diff --git a/kernel/drivers/pit.c b/kernel/drivers/pit.c
index 30fd3ed..41c0d2a 100644
--- a/kernel/drivers/pit.c
+++ b/kernel/drivers/pit.c
@@ -44,16 +44,14 @@ void set_pit_count(u16 _hertz) {
}
void int_clock(reg_t *regs) {
- EOI(0x20);
- pit_counter++;
- if (pit_counter * 1000 >= hertz) {
- pit_counter = 0;
- clock_num_ms_ticks += 1000 / hertz;
- }
+ clock_num_ms_ticks++;
switch_counter++;
- if (switch_counter * 500 >= hertz) {
+ if (switch_counter >= hertz) {
+ EOI(0x20);
switch_counter = 0;
switch_task();
+ } else {
+ EOI(0x20);
}
}