1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 15:17:36 +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

@ -65,7 +65,6 @@ public:
__Begin_Blocked_States__,
BlockedLurking,
BlockedSleep,
BlockedWait,
BlockedSignal,
BlockedSelect,
@ -127,6 +126,15 @@ public:
Function<bool()> m_block_until_condition;
};
class ThreadBlockerSleep : public ThreadBlocker {
public:
ThreadBlockerSleep(u64 wakeup_time);
virtual bool should_unblock(time_t, long) override;
private:
u64 m_wakeup_time { 0 };
};
void did_schedule() { ++m_times_scheduled; }
u32 times_scheduled() const { return m_times_scheduled; }
@ -146,13 +154,11 @@ public:
u32 ticks() const { return m_ticks; }
pid_t waitee_pid() const { return m_waitee_pid; }
void sleep(u32 ticks);
u64 sleep(u32 ticks);
void block(Thread::State);
void block(ThreadBlocker& blocker);
void unblock();
void set_wakeup_time(u64 t) { m_wakeup_time = t; }
u64 wakeup_time() const { return m_wakeup_time; }
void block_until(Function<bool()>&&);
KResult wait_for_connect(FileDescription&);
@ -226,7 +232,6 @@ private:
FarPtr m_far_ptr;
u32 m_ticks { 0 };
u32 m_ticks_left { 0 };
u64 m_wakeup_time { 0 };
u32 m_times_scheduled { 0 };
u32 m_pending_signals { 0 };
u32 m_signal_mask { 0 };