Kernel: Make sleep syscall interruptable

This commit is contained in:
Bananymous 2023-12-06 13:12:56 +02:00
parent ff8b3be8dc
commit a12ffaa8a2
1 changed files with 8 additions and 1 deletions

View File

@ -598,7 +598,14 @@ namespace Kernel
BAN::ErrorOr<long> Process::sys_sleep(int seconds)
{
SystemTimer::get().sleep(seconds * 1000);
// FIXME: this is very dumb
uint64_t wake_time = SystemTimer::get().ms_since_boot() + seconds * 1000;
while (SystemTimer::get().ms_since_boot() < wake_time)
{
if (Thread::current().is_interrupted_by_signal())
return BAN::Math::div_round_up<long>(wake_time - SystemTimer::get().ms_since_boot(), 1000);
Scheduler::get().reschedule();
}
return 0;
}