diff options
author | Anton Kling <anton@kling.gg> | 2024-02-19 19:19:43 +0100 |
---|---|---|
committer | Anton Kling <anton@kling.gg> | 2024-02-19 19:19:43 +0100 |
commit | a85eacdd2406fede4d6ff5cb130b1758978cabb3 (patch) | |
tree | 1e7ea908f37c39e26633d2638b23045fcc231ede /kernel | |
parent | 239e33019117f4ab59dd26550d7969e45c290166 (diff) |
Kernel: Change timing for context switches
Diffstat (limited to 'kernel')
-rw-r--r-- | kernel/drivers/pit.c | 14 | ||||
-rw-r--r-- | kernel/init/kernel.c | 2 |
2 files changed, 11 insertions, 5 deletions
diff --git a/kernel/drivers/pit.c b/kernel/drivers/pit.c index 1e9048f..060fc54 100644 --- a/kernel/drivers/pit.c +++ b/kernel/drivers/pit.c @@ -4,7 +4,8 @@ #define PIT_IO_MODE_COMMAND 0x43 u64 clock_num_ms_ticks = 0; -u64 pit_counter = 0; +u32 pit_counter = 0; +u32 switch_counter = 0; u16 hertz; u64 pit_num_ms(void) { @@ -22,7 +23,8 @@ u16 read_pit_count(void) { return count; } -void set_pit_count(u16 hertz) { +void set_pit_count(u16 _hertz) { + hertz = _hertz; u16 divisor = 1193180 / hertz; /* @@ -44,9 +46,13 @@ void set_pit_count(u16 hertz) { void int_clock(reg_t regs) { outb(0x20, 0x20); pit_counter++; - if (pit_counter*1000 >= hertz) { + if (pit_counter * 1000 >= hertz) { pit_counter = 0; - clock_num_ms_ticks++; + clock_num_ms_ticks += 1000 / hertz; + } + switch_counter++; + if (switch_counter * 500 >= hertz) { + switch_counter = 0; switch_task(); } } diff --git a/kernel/init/kernel.c b/kernel/init/kernel.c index 6b160a6..55c65b2 100644 --- a/kernel/init/kernel.c +++ b/kernel/init/kernel.c @@ -67,7 +67,7 @@ void kernel_main(u32 kernel_end, unsigned long magic, unsigned long addr, klog("Syscalls Initalized", LOG_SUCCESS); pit_install(); - set_pit_count(500); + set_pit_count(100); klog("PIT driver installed", LOG_SUCCESS); ata_init(); |