diff options
author | Tom <tomut@yahoo.com> | 2020-09-05 15:52:14 -0600 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2021-01-01 23:43:44 +0100 |
commit | 476f17b3f18234f9d66ba112df77e248a17e2f6f (patch) | |
tree | 0e4f1cd52ae1d33a39cffcac8a70a5f9c250c3d1 /Kernel/Thread.cpp | |
parent | b2a52f62089e4799336cf0bf32eb307b077d2e72 (diff) | |
download | serenity-476f17b3f18234f9d66ba112df77e248a17e2f6f.zip |
Kernel: Merge PurgeableVMObject into AnonymousVMObject
This implements memory commitments and lazy-allocation of committed
memory.
Diffstat (limited to 'Kernel/Thread.cpp')
-rw-r--r-- | Kernel/Thread.cpp | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/Kernel/Thread.cpp b/Kernel/Thread.cpp index e1b1bd5e5a..2b7e1b7ea6 100644 --- a/Kernel/Thread.cpp +++ b/Kernel/Thread.cpp @@ -86,7 +86,12 @@ Thread::Thread(NonnullRefPtr<Process> process) m_tss.cr3 = m_process->page_directory().cr3(); - m_kernel_stack_region = MM.allocate_kernel_region(default_kernel_stack_size, String::format("Kernel Stack (Thread %d)", m_tid.value()), Region::Access::Read | Region::Access::Write, false, true); + m_kernel_stack_region = MM.allocate_kernel_region(default_kernel_stack_size, String::format("Kernel Stack (Thread %d)", 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; @@ -858,6 +863,10 @@ RegisterState& Thread::get_register_dump_from_stack() RefPtr<Thread> Thread::clone(Process& process) { auto clone = adopt(*new Thread(process)); + if (!clone->was_created()) { + // We failed to clone this thread + return {}; + } memcpy(clone->m_signal_action_data, m_signal_action_data, sizeof(m_signal_action_data)); clone->m_signal_mask = m_signal_mask; memcpy(clone->m_fpu_state, m_fpu_state, sizeof(FPUState)); @@ -1052,7 +1061,7 @@ KResult Thread::make_thread_specific_region(Badge<Process>) if (!process().m_master_tls_region) return KSuccess; - auto* region = process().allocate_region({}, thread_specific_region_size(), "Thread-specific", PROT_READ | PROT_WRITE, true); + auto* region = process().allocate_region({}, thread_specific_region_size(), "Thread-specific", PROT_READ | PROT_WRITE); if (!region) return KResult(-ENOMEM); |