1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 09:08:12 +00:00

Kernel: Port sleep to ThreadBlocker

This commit is contained in:
Robin Burchell 2019-07-18 17:26:11 +02:00 committed by Andreas Kling
parent 0c8813e6d9
commit 32fcfb79e9
4 changed files with 30 additions and 20 deletions

View file

@ -1289,10 +1289,10 @@ int Process::sys$usleep(useconds_t usec)
if (!usec)
return 0;
current->sleep(usec / 1000);
if (current->m_wakeup_time > g_uptime) {
u64 wakeup_time = current->sleep(usec / 1000);
if (wakeup_time > g_uptime) {
ASSERT(current->m_was_interrupted_while_blocked);
u32 ticks_left_until_original_wakeup_time = current->m_wakeup_time - g_uptime;
u32 ticks_left_until_original_wakeup_time = wakeup_time - g_uptime;
return ticks_left_until_original_wakeup_time / TICKS_PER_SECOND;
}
return 0;
@ -1302,10 +1302,10 @@ int Process::sys$sleep(unsigned seconds)
{
if (!seconds)
return 0;
current->sleep(seconds * TICKS_PER_SECOND);
if (current->m_wakeup_time > g_uptime) {
u64 wakeup_time = current->sleep(seconds * TICKS_PER_SECOND);
if (wakeup_time > g_uptime) {
ASSERT(current->m_was_interrupted_while_blocked);
u32 ticks_left_until_original_wakeup_time = current->m_wakeup_time - g_uptime;
u32 ticks_left_until_original_wakeup_time = wakeup_time - g_uptime;
return ticks_left_until_original_wakeup_time / TICKS_PER_SECOND;
}
return 0;