kernel: Tweak some timer code
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
apio 2023-11-04 10:47:41 +01:00
parent dfebdce689
commit e28e1c682c
Signed by: apio
GPG Key ID: B8A7D06E42258954
2 changed files with 5 additions and 1 deletions

View File

@ -13,7 +13,10 @@ Result<u64> 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<Scheduler::Timer>());

View File

@ -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;