diff options
author | Andreas Kling <kling@serenityos.org> | 2021-02-07 20:13:51 +0100 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2021-02-07 20:13:51 +0100 |
commit | 2ec8b4e1776c5b6e6d9a071f8456866621af572f (patch) | |
tree | b6a5cb1bb79936279dcdf296918351aed9fa48a0 /Kernel/Thread.cpp | |
parent | 33c7017f6ee30099d5f7fd888e8af8d5acc44de7 (diff) | |
download | serenity-2ec8b4e1776c5b6e6d9a071f8456866621af572f.zip |
Kernel: Don't allocate kernel stack twice per thread :^)
Diffstat (limited to 'Kernel/Thread.cpp')
-rw-r--r-- | Kernel/Thread.cpp | 8 |
1 files changed, 1 insertions, 7 deletions
diff --git a/Kernel/Thread.cpp b/Kernel/Thread.cpp index 2b13ac92fa..d42d4ce51e 100644 --- a/Kernel/Thread.cpp +++ b/Kernel/Thread.cpp @@ -58,6 +58,7 @@ KResultOr<NonnullRefPtr<Thread>> Thread::try_create(NonnullRefPtr<Process> proce auto kernel_stack_region = MM.allocate_kernel_region(default_kernel_stack_size, {}, Region::Access::Read | Region::Access::Write, false, AllocationStrategy::AllocateNow); if (!kernel_stack_region) return ENOMEM; + kernel_stack_region->set_stack(true); return adopt(*new Thread(move(process), kernel_stack_region.release_nonnull())); } @@ -109,13 +110,6 @@ Thread::Thread(NonnullRefPtr<Process> process, NonnullOwnPtr<Region> kernel_stac m_tss.cr3 = m_process->page_directory().cr3(); - m_kernel_stack_region = MM.allocate_kernel_region(default_kernel_stack_size, String::formatted("Kernel Stack (Thread {})", m_tid.value()), Region::Access::Read | Region::Access::Write, false, AllocationStrategy::AllocateNow); - if (!m_kernel_stack_region) { - // Abort creating this thread, was_created() will return false - return; - } - - m_kernel_stack_region->set_stack(true); m_kernel_stack_base = m_kernel_stack_region->vaddr().get(); m_kernel_stack_top = m_kernel_stack_region->vaddr().offset(default_kernel_stack_size).get() & 0xfffffff8u; |