mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 07:17:35 +00:00
Kernel: Move "in-scheduler" flag from SchedulerData to Processor
This avoids a race between getting the processor-specific SchedulerData and accessing it. (Switching to a different CPU in that window means that we're operating on the wrong SchedulerData.) Co-authored-by: Tom <tomut@yahoo.com>
This commit is contained in:
parent
249d6a490d
commit
d9da513959
2 changed files with 24 additions and 22 deletions
|
@ -25,7 +25,6 @@ struct ProcessorMessageEntry;
|
|||
|
||||
enum class ProcessorSpecificDataID {
|
||||
MemoryManager,
|
||||
Scheduler,
|
||||
__Count,
|
||||
};
|
||||
|
||||
|
@ -138,6 +137,7 @@ class Processor {
|
|||
|
||||
bool m_invoke_scheduler_async;
|
||||
bool m_scheduler_initialized;
|
||||
bool m_in_scheduler { true };
|
||||
Atomic<bool> m_halt_requested;
|
||||
|
||||
DeferredCallEntry* m_pending_deferred_calls; // in reverse order
|
||||
|
@ -344,6 +344,16 @@ public:
|
|||
write_gs_ptr(__builtin_offsetof(Processor, m_in_critical), in_critical() + 1);
|
||||
}
|
||||
|
||||
ALWAYS_INLINE static bool current_in_scheduler()
|
||||
{
|
||||
return read_gs_value<decltype(m_in_scheduler)>(__builtin_offsetof(Processor, m_in_scheduler));
|
||||
}
|
||||
|
||||
ALWAYS_INLINE static void set_current_in_scheduler(bool value)
|
||||
{
|
||||
write_gs_value<decltype(m_in_scheduler)>(__builtin_offsetof(Processor, m_in_scheduler), value);
|
||||
}
|
||||
|
||||
private:
|
||||
ALWAYS_INLINE void do_leave_critical()
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue