mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 10:48:11 +00:00
Kernel: Port sleep to ThreadBlocker
This commit is contained in:
parent
0c8813e6d9
commit
32fcfb79e9
4 changed files with 30 additions and 20 deletions
|
@ -133,6 +133,16 @@ bool Thread::ThreadBlockerCondition::should_unblock(time_t, long)
|
|||
return m_block_until_condition();
|
||||
}
|
||||
|
||||
Thread::ThreadBlockerSleep::ThreadBlockerSleep(u64 wakeup_time)
|
||||
: m_wakeup_time(wakeup_time)
|
||||
{
|
||||
}
|
||||
|
||||
bool Thread::ThreadBlockerSleep::should_unblock(time_t, long)
|
||||
{
|
||||
return m_wakeup_time <= g_uptime;
|
||||
}
|
||||
|
||||
// Called by the scheduler on threads that are blocked for some reason.
|
||||
// Make a decision as to whether to unblock them or not.
|
||||
void Thread::consider_unblock(time_t now_sec, long now_usec)
|
||||
|
@ -152,10 +162,6 @@ void Thread::consider_unblock(time_t now_sec, long now_usec)
|
|||
case Thread::BlockedSignal:
|
||||
/* don't know, don't care */
|
||||
return;
|
||||
case Thread::BlockedSleep:
|
||||
if (wakeup_time() <= g_uptime)
|
||||
unblock();
|
||||
return;
|
||||
case Thread::BlockedWait:
|
||||
process.for_each_child([&](Process& child) {
|
||||
if (waitee_pid() != -1 && waitee_pid() != child.pid())
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue