kernel: Fix current_process race
TSan reported a race at :258 and :803, so make current_process an atomic pointer.
This commit is contained in:
parent
83b86d915a
commit
5b5a1b7fa7
@ -84,7 +84,7 @@ struct KernelCore::Impl {
|
|||||||
|
|
||||||
void InitializeCores() {
|
void InitializeCores() {
|
||||||
for (u32 core_id = 0; core_id < Core::Hardware::NUM_CPU_CORES; core_id++) {
|
for (u32 core_id = 0; core_id < Core::Hardware::NUM_CPU_CORES; core_id++) {
|
||||||
cores[core_id].Initialize(current_process->Is64BitProcess());
|
cores[core_id].Initialize((*current_process).Is64BitProcess());
|
||||||
system.Memory().SetCurrentPageTable(*current_process, core_id);
|
system.Memory().SetCurrentPageTable(*current_process, core_id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -167,11 +167,11 @@ struct KernelCore::Impl {
|
|||||||
|
|
||||||
// Shutdown all processes.
|
// Shutdown all processes.
|
||||||
if (current_process) {
|
if (current_process) {
|
||||||
current_process->Finalize();
|
(*current_process).Finalize();
|
||||||
// current_process->Close();
|
// current_process->Close();
|
||||||
// TODO: The current process should be destroyed based on accurate ref counting after
|
// TODO: The current process should be destroyed based on accurate ref counting after
|
||||||
// calling Close(). Adding a manual Destroy() call instead to avoid a memory leak.
|
// calling Close(). Adding a manual Destroy() call instead to avoid a memory leak.
|
||||||
current_process->Destroy();
|
(*current_process).Destroy();
|
||||||
current_process = nullptr;
|
current_process = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -697,7 +697,7 @@ struct KernelCore::Impl {
|
|||||||
|
|
||||||
// Lists all processes that exist in the current session.
|
// Lists all processes that exist in the current session.
|
||||||
std::vector<KProcess*> process_list;
|
std::vector<KProcess*> process_list;
|
||||||
KProcess* current_process{};
|
std::atomic<KProcess*> current_process{};
|
||||||
std::unique_ptr<Kernel::GlobalSchedulerContext> global_scheduler_context;
|
std::unique_ptr<Kernel::GlobalSchedulerContext> global_scheduler_context;
|
||||||
Kernel::TimeManager time_manager;
|
Kernel::TimeManager time_manager;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user