|
@@ -67,7 +67,6 @@ public:
|
|
BlockedLurking,
|
|
BlockedLurking,
|
|
BlockedWait,
|
|
BlockedWait,
|
|
BlockedSignal,
|
|
BlockedSignal,
|
|
- BlockedSelect,
|
|
|
|
BlockedCondition,
|
|
BlockedCondition,
|
|
__End_Blocked_States__
|
|
__End_Blocked_States__
|
|
};
|
|
};
|
|
@@ -75,7 +74,7 @@ public:
|
|
class ThreadBlocker {
|
|
class ThreadBlocker {
|
|
public:
|
|
public:
|
|
virtual ~ThreadBlocker() {}
|
|
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 {
|
|
class ThreadBlockerFileDescription : public ThreadBlocker {
|
|
@@ -90,37 +89,37 @@ public:
|
|
class ThreadBlockerAccept : public ThreadBlockerFileDescription {
|
|
class ThreadBlockerAccept : public ThreadBlockerFileDescription {
|
|
public:
|
|
public:
|
|
ThreadBlockerAccept(const RefPtr<FileDescription>& description);
|
|
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 {
|
|
class ThreadBlockerReceive : public ThreadBlockerFileDescription {
|
|
public:
|
|
public:
|
|
ThreadBlockerReceive(const RefPtr<FileDescription>& description);
|
|
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 {
|
|
class ThreadBlockerConnect : public ThreadBlockerFileDescription {
|
|
public:
|
|
public:
|
|
ThreadBlockerConnect(const RefPtr<FileDescription>& description);
|
|
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 {
|
|
class ThreadBlockerWrite : public ThreadBlockerFileDescription {
|
|
public:
|
|
public:
|
|
ThreadBlockerWrite(const RefPtr<FileDescription>& description);
|
|
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 {
|
|
class ThreadBlockerRead : public ThreadBlockerFileDescription {
|
|
public:
|
|
public:
|
|
ThreadBlockerRead(const RefPtr<FileDescription>& description);
|
|
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 {
|
|
class ThreadBlockerCondition : public ThreadBlocker {
|
|
public:
|
|
public:
|
|
ThreadBlockerCondition(Function<bool()> &condition);
|
|
ThreadBlockerCondition(Function<bool()> &condition);
|
|
- virtual bool should_unblock(time_t, long) override;
|
|
|
|
|
|
+ virtual bool should_unblock(Thread&, time_t, long) override;
|
|
|
|
|
|
private:
|
|
private:
|
|
Function<bool()> m_block_until_condition;
|
|
Function<bool()> m_block_until_condition;
|
|
@@ -129,12 +128,25 @@ public:
|
|
class ThreadBlockerSleep : public ThreadBlocker {
|
|
class ThreadBlockerSleep : public ThreadBlocker {
|
|
public:
|
|
public:
|
|
ThreadBlockerSleep(u64 wakeup_time);
|
|
ThreadBlockerSleep(u64 wakeup_time);
|
|
- virtual bool should_unblock(time_t, long) override;
|
|
|
|
|
|
+ virtual bool should_unblock(Thread&, time_t, long) override;
|
|
|
|
|
|
private:
|
|
private:
|
|
u64 m_wakeup_time { 0 };
|
|
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; }
|
|
void did_schedule() { ++m_times_scheduled; }
|
|
u32 times_scheduled() const { return 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;
|
|
RefPtr<Region> m_kernel_stack_for_signal_handler_region;
|
|
pid_t m_waitee_pid { -1 };
|
|
pid_t m_waitee_pid { -1 };
|
|
int m_wait_options { 0 };
|
|
int m_wait_options { 0 };
|
|
- timeval m_select_timeout;
|
|
|
|
SignalActionData m_signal_action_data[32];
|
|
SignalActionData m_signal_action_data[32];
|
|
Region* m_signal_stack_user_region { nullptr };
|
|
Region* m_signal_stack_user_region { nullptr };
|
|
OwnPtr<ThreadBlocker> m_blocker;
|
|
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 };
|
|
FPUState* m_fpu_state { nullptr };
|
|
InlineLinkedList<Thread>* m_thread_list { nullptr };
|
|
InlineLinkedList<Thread>* m_thread_list { nullptr };
|
|
State m_state { Invalid };
|
|
State m_state { Invalid };
|
|
- bool m_select_has_timeout { false };
|
|
|
|
bool m_has_used_fpu { false };
|
|
bool m_has_used_fpu { false };
|
|
bool m_was_interrupted_while_blocked { false };
|
|
bool m_was_interrupted_while_blocked { false };
|
|
};
|
|
};
|