From a164ca67174ba6179170dea573479f23122513cc Mon Sep 17 00:00:00 2001 From: Aleksa Vuckovic Date: Sun, 26 Feb 2023 13:22:31 +0100 Subject: process.c --- kernel/src/devices/timer.c | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) (limited to 'kernel/src/devices/timer.c') diff --git a/kernel/src/devices/timer.c b/kernel/src/devices/timer.c index 0f6fc20..7971b20 100644 --- a/kernel/src/devices/timer.c +++ b/kernel/src/devices/timer.c @@ -4,8 +4,10 @@ #include #include #include +#include -uint32_t tick = 0; +uint32_t scheduler_ticks = 0; +uint32_t seconds_tick = 0; uint32_t seconds = 0; struct wait_queue { @@ -23,12 +25,16 @@ void timer_handler(uint64_t rsp) pos->ticks--; } - tick++; - - if (tick >= TICKS_PER_SECOND) { - tick = 0; + seconds_tick++; + if (seconds_tick >= TICKS_PER_SECOND) { + seconds_tick = 0; seconds++; } + scheduler_ticks++; + if (scheduler_ticks >= TICKS_PER_SECOND / CONTEXT_SWITCHES_PER_SECOND) { + scheduler_ticks = 0; +/* context_switch(rsp); */ + } } void wait(uint64_t ms) -- cgit v1.2.3