kernel: Fix 0-delay sleeps blocking the thread forever
This commit is contained in:
parent
85896214ba
commit
d0b65674e6
@ -6,6 +6,9 @@ Result<u64> sys_usleep(Registers*, SyscallArgs args)
|
|||||||
{
|
{
|
||||||
useconds_t us = (useconds_t)args[0];
|
useconds_t us = (useconds_t)args[0];
|
||||||
|
|
||||||
|
// FIXME: Allow usleep() to use a more precise resolution.
|
||||||
|
if (us < 1000) return 0;
|
||||||
|
|
||||||
kernel_sleep(us / 1000);
|
kernel_sleep(us / 1000);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -271,7 +271,7 @@ namespace Scheduler
|
|||||||
{
|
{
|
||||||
if (thread->state == ThreadState::Sleeping)
|
if (thread->state == ThreadState::Sleeping)
|
||||||
{
|
{
|
||||||
if (--thread->sleep_ticks_left == 0) thread->wake_up();
|
if (thread->sleep_ticks_left == 0 || --thread->sleep_ticks_left == 0) thread->wake_up();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user