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/drivers/pit.c | |
parent | 239e33019117f4ab59dd26550d7969e45c290166 (diff) |
Kernel: Change timing for context switches
Diffstat (limited to 'kernel/drivers/pit.c')
-rw-r--r-- | kernel/drivers/pit.c | 14 |
1 files changed, 10 insertions, 4 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(); } } |