summaryrefslogtreecommitdiff
path: root/Kernel/Thread.h
diff options
context:
space:
mode:
authorRobin Burchell <robin+git@viroteck.net>2019-07-18 17:39:49 +0200
committerAndreas Kling <awesomekling@gmail.com>2019-07-19 11:03:22 +0200
commit4f9ae9b970fe658136fcc208ba2e23ab10161644 (patch)
tree2c962a5f00f4c8e2433615f2ec3bbc8727309c48 /Kernel/Thread.h
parent32fcfb79e93d9de45328997950d69f4d1f0d12be (diff)
downloadserenity-4f9ae9b970fe658136fcc208ba2e23ab10161644.zip
Kernel: Port select to ThreadBlocker
Diffstat (limited to 'Kernel/Thread.h')
-rw-r--r--Kernel/Thread.h35
1 files changed, 21 insertions, 14 deletions
diff --git a/Kernel/Thread.h b/Kernel/Thread.h
index 92d67d80bc..f356deccad 100644
--- a/Kernel/Thread.h
+++ b/Kernel/Thread.h
@@ -67,7 +67,6 @@ public:
BlockedLurking,
BlockedWait,
BlockedSignal,
- BlockedSelect,
BlockedCondition,
__End_Blocked_States__
};
@@ -75,7 +74,7 @@ public:
class ThreadBlocker {
public:
virtual ~ThreadBlocker() {}
- virtual bool should_unblock(time_t now_s, long us) = 0;
+ virtual bool should_unblock(Thread&, time_t now_s, long us) = 0;
};
class ThreadBlockerFileDescription : public ThreadBlocker {
@@ -90,37 +89,37 @@ public:
class ThreadBlockerAccept : public ThreadBlockerFileDescription {
public:
ThreadBlockerAccept(const RefPtr<FileDescription>& description);
- virtual bool should_unblock(time_t, long) override;
+ virtual bool should_unblock(Thread&, time_t, long) override;
};
class ThreadBlockerReceive : public ThreadBlockerFileDescription {
public:
ThreadBlockerReceive(const RefPtr<FileDescription>& description);
- virtual bool should_unblock(time_t, long) override;
+ virtual bool should_unblock(Thread&, time_t, long) override;
};
class ThreadBlockerConnect : public ThreadBlockerFileDescription {
public:
ThreadBlockerConnect(const RefPtr<FileDescription>& description);
- virtual bool should_unblock(time_t, long) override;
+ virtual bool should_unblock(Thread&, time_t, long) override;
};
class ThreadBlockerWrite : public ThreadBlockerFileDescription {
public:
ThreadBlockerWrite(const RefPtr<FileDescription>& description);
- virtual bool should_unblock(time_t, long) override;
+ virtual bool should_unblock(Thread&, time_t, long) override;
};
class ThreadBlockerRead : public ThreadBlockerFileDescription {
public:
ThreadBlockerRead(const RefPtr<FileDescription>& description);
- virtual bool should_unblock(time_t, long) override;
+ virtual bool should_unblock(Thread&, time_t, long) override;
};
class ThreadBlockerCondition : public ThreadBlocker {
public:
ThreadBlockerCondition(Function<bool()> &condition);
- virtual bool should_unblock(time_t, long) override;
+ virtual bool should_unblock(Thread&, time_t, long) override;
private:
Function<bool()> m_block_until_condition;
@@ -129,12 +128,25 @@ public:
class ThreadBlockerSleep : public ThreadBlocker {
public:
ThreadBlockerSleep(u64 wakeup_time);
- virtual bool should_unblock(time_t, long) override;
+ virtual bool should_unblock(Thread&, time_t, long) override;
private:
u64 m_wakeup_time { 0 };
};
+ class ThreadBlockerSelect : public ThreadBlocker {
+ public:
+ ThreadBlockerSelect(const timeval& tv, bool select_has_timeout, const Vector<int>& read_fds, const Vector<int>& write_fds, const Vector<int>& except_fds);
+ virtual bool should_unblock(Thread&, time_t, long) override;
+
+ private:
+ timeval m_select_timeout;
+ bool m_select_has_timeout { false };
+ const Vector<int>& m_select_read_fds;
+ const Vector<int>& m_select_write_fds;
+ const Vector<int>& m_select_exceptional_fds;
+ };
+
void did_schedule() { ++m_times_scheduled; }
u32 times_scheduled() const { return m_times_scheduled; }
@@ -240,17 +252,12 @@ private:
RefPtr<Region> m_kernel_stack_for_signal_handler_region;
pid_t m_waitee_pid { -1 };
int m_wait_options { 0 };
- timeval m_select_timeout;
SignalActionData m_signal_action_data[32];
Region* m_signal_stack_user_region { nullptr };
OwnPtr<ThreadBlocker> m_blocker;
- Vector<int> m_select_read_fds;
- Vector<int> m_select_write_fds;
- Vector<int> m_select_exceptional_fds;
FPUState* m_fpu_state { nullptr };
InlineLinkedList<Thread>* m_thread_list { nullptr };
State m_state { Invalid };
- bool m_select_has_timeout { false };
bool m_has_used_fpu { false };
bool m_was_interrupted_while_blocked { false };
};