Skip to content

Commit

Permalink
system/time: Warn if waiting without an active clock source
Browse files Browse the repository at this point in the history
  • Loading branch information
marv7000 committed Nov 29, 2024
1 parent 78e94a3 commit 0a63c08
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions kernel/system/time/clock.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,14 @@ usize clock_get_elapsed()

void clock_wait(usize ns)
{
if (current_source == NULL)
{
print_warn("clock: Attempted to wait %zu nanoseconds, "
"but this would hang indefinitely since no clock source is available.\n",
ns);
return;
}

usize time = clock_get_elapsed() + ns;
while (time > clock_get_elapsed())
{
Expand Down

0 comments on commit 0a63c08

Please sign in to comment.