1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 21:37:35 +00:00

Kernel: Store whether a thread is the idle thread in Thread directly

This solves a problem where checking whether a thread is an idle
thread may require iterating all processors if it is not the idle
thread of the current processor.
This commit is contained in:
Tom 2021-01-28 20:07:41 -07:00 committed by Andreas Kling
parent 9a69b9112b
commit ec27cbbb2a
3 changed files with 15 additions and 11 deletions

View file

@ -779,11 +779,6 @@ public:
return *m_mm_data;
}
ALWAYS_INLINE Thread* idle_thread() const
{
return m_idle_thread;
}
ALWAYS_INLINE void set_idle_thread(Thread& idle_thread)
{
m_idle_thread = &idle_thread;
@ -806,6 +801,12 @@ public:
write_fs_u32(__builtin_offsetof(Processor, m_current_thread), FlatPtr(&current_thread));
}
ALWAYS_INLINE static Thread* idle_thread()
{
// See comment in Processor::current_thread
return (Thread*)read_fs_u32(__builtin_offsetof(Processor, m_idle_thread));
}
ALWAYS_INLINE u32 get_id() const
{
// NOTE: This variant should only be used when iterating over all