From 9257facb17bf74eb0eb1babfc59ff3549eb66242 Mon Sep 17 00:00:00 2001 From: Marvin Borner Date: Tue, 24 Nov 2020 16:42:10 +0100 Subject: Fixed timer counting with yield() --- kernel/drivers/timer.c | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) (limited to 'kernel/drivers') diff --git a/kernel/drivers/timer.c b/kernel/drivers/timer.c index 17a8991..766512f 100644 --- a/kernel/drivers/timer.c +++ b/kernel/drivers/timer.c @@ -3,8 +3,10 @@ #include #include #include +#include static u32 timer_ticks = 0; +static u8 call_scheduler = 0; void timer_phase(int hz) { @@ -19,12 +21,15 @@ u32 timer_get(void) return timer_ticks; } -void timer_handler() +void timer_handler(struct regs *r) { if (timer_ticks >= U32_MAX) timer_ticks = 0; else timer_ticks++; + + if (call_scheduler) + scheduler(r); } // "Delay" function with CPU sleep @@ -44,3 +49,15 @@ void timer_install(void) timer_phase(1000); irq_install_handler(0, timer_handler); } + +void scheduler_enable(void) +{ + call_scheduler = 1; + irq_install_handler(0, timer_handler); +} + +void scheduler_disable(void) +{ + call_scheduler = 0; + irq_install_handler(0, timer_handler); +} -- cgit v1.2.3