diff --git a/kernel/src/sys/alarm.cpp b/kernel/src/sys/alarm.cpp index 83f86b66..cf4da65c 100644 --- a/kernel/src/sys/alarm.cpp +++ b/kernel/src/sys/alarm.cpp @@ -13,7 +13,10 @@ Result sys_alarm(Registers*, SyscallArgs args) u64 ticks_left = current->timer ? current->timer->ticks_left() : 0; - if (current->timer) Scheduler::remove_from_timer_queue(current->timer); + if (current->timer) + { + if (current->timer->delta_ticks > 0) Scheduler::remove_from_timer_queue(current->timer); + } else current->timer = TRY(make()); diff --git a/kernel/src/thread/Timer.cpp b/kernel/src/thread/Timer.cpp index dc8c94d1..d58ea281 100644 --- a/kernel/src/thread/Timer.cpp +++ b/kernel/src/thread/Timer.cpp @@ -62,6 +62,7 @@ namespace Scheduler u64 Timer::ticks_left() { u64 total = 0; + if (delta_ticks == 0) return 0; for (auto* t : g_timer_queue) { total += t->delta_ticks;