blob: aeded3697b422e1b98486dc43bb86d3bbe95a61d (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
|
/*
* Copyright (c) 2018-2020, Andreas Kling <kling@serenityos.org>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#include <Kernel/VM/MemoryManager.h>
#include <Kernel/VM/VMObject.h>
namespace Kernel {
VMObject::VMObject(VMObject const& other)
: m_physical_pages(other.m_physical_pages)
{
MM.register_vmobject(*this);
}
VMObject::VMObject(size_t size)
: m_physical_pages(ceil_div(size, static_cast<size_t>(PAGE_SIZE)))
{
MM.register_vmobject(*this);
}
VMObject::~VMObject()
{
{
ScopedSpinLock lock(m_on_deleted_lock);
for (auto& it : m_on_deleted)
it->vmobject_deleted(*this);
m_on_deleted.clear();
}
MM.unregister_vmobject(*this);
VERIFY(m_regions_count.load(AK::MemoryOrder::memory_order_relaxed) == 0);
}
}
|