mirror of
https://github.com/RGBCube/serenity
synced 2025-07-28 09:57:36 +00:00
Kernel: Turn Thread::current and Process::current into functions
This allows us to query the current thread and process on a per processor basis
This commit is contained in:
parent
cdc78515b6
commit
16783bd14d
39 changed files with 518 additions and 369 deletions
|
@ -626,6 +626,8 @@ class Processor {
|
|||
static FPUState s_clean_fpu_state;
|
||||
|
||||
ProcessorInfo* m_info;
|
||||
Thread* m_current_thread;
|
||||
Thread* m_idle_thread;
|
||||
|
||||
bool m_invoke_scheduler_async;
|
||||
|
||||
|
@ -661,6 +663,33 @@ public:
|
|||
return *(Processor*)read_fs_u32(0);
|
||||
}
|
||||
|
||||
ALWAYS_INLINE static bool is_initialized()
|
||||
{
|
||||
return get_fs() == GDT_SELECTOR_PROC && read_fs_u32(0) != 0;
|
||||
}
|
||||
|
||||
ALWAYS_INLINE Thread* idle_thread() const
|
||||
{
|
||||
return m_idle_thread;
|
||||
}
|
||||
|
||||
ALWAYS_INLINE void set_idle_thread(Thread& idle_thread)
|
||||
{
|
||||
m_idle_thread = &idle_thread;
|
||||
}
|
||||
|
||||
ALWAYS_INLINE Thread* current_thread() const
|
||||
{
|
||||
// NOTE: NOT safe to call from another processor!
|
||||
ASSERT(&Processor::current() == this);
|
||||
return m_current_thread;
|
||||
}
|
||||
|
||||
ALWAYS_INLINE void set_current_thread(Thread& current_thread)
|
||||
{
|
||||
m_current_thread = ¤t_thread;
|
||||
}
|
||||
|
||||
ALWAYS_INLINE u32 id()
|
||||
{
|
||||
return m_cpu;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue