Kernel: Make it easier to add Thread block states in the future.

This commit is contained in:
Andreas Kling 2019-07-13 20:14:39 +02:00
parent 302cae5c2f
commit 54e79a4640
Notes: sideshowbarker 2024-07-19 13:17:44 +09:00
2 changed files with 7 additions and 1 deletions

View File

@ -181,6 +181,9 @@ const char* to_string(Thread::State state)
return "Receive";
case Thread::BlockedSnoozing:
return "Snoozing";
case Thread::__Begin_Blocked_States__:
case Thread::__End_Blocked_States__:
break;
}
kprintf("to_string(Thread::State): Invalid state: %u\n", state);
ASSERT_NOT_REACHED();

View File

@ -61,6 +61,8 @@ public:
Dying,
Dead,
Stopped,
__Begin_Blocked_States__,
BlockedLurking,
BlockedSleep,
BlockedWait,
@ -71,6 +73,7 @@ public:
BlockedConnect,
BlockedReceive,
BlockedSnoozing,
__End_Blocked_States__
};
void did_schedule() { ++m_times_scheduled; }
@ -79,7 +82,7 @@ public:
bool is_stopped() const { return m_state == Stopped; }
bool is_blocked() const
{
return m_state == BlockedSleep || m_state == BlockedWait || m_state == BlockedRead || m_state == BlockedWrite || m_state == BlockedSignal || m_state == BlockedSelect;
return m_state > __Begin_Blocked_States__ && m_state < __End_Blocked_States__;
}
bool in_kernel() const { return (m_tss.cs & 0x03) == 0; }