mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 06:38:10 +00:00

We only ever use private futexes, so it doesn't make sense to carry around all the complexity required for global (cross-process) futexes.
37 lines
846 B
C++
37 lines
846 B
C++
/*
|
|
* Copyright (c) 2018-2021, Andreas Kling <kling@serenityos.org>
|
|
*
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
|
*/
|
|
|
|
#include <AK/Singleton.h>
|
|
#include <Kernel/Memory/MemoryManager.h>
|
|
#include <Kernel/Memory/VMObject.h>
|
|
|
|
namespace Kernel::Memory {
|
|
|
|
static Singleton<SpinLockProtectedValue<VMObject::AllInstancesList>> s_all_instances;
|
|
|
|
SpinLockProtectedValue<VMObject::AllInstancesList>& VMObject::all_instances()
|
|
{
|
|
return s_all_instances;
|
|
}
|
|
|
|
VMObject::VMObject(VMObject const& other)
|
|
: m_physical_pages(other.m_physical_pages)
|
|
{
|
|
all_instances().with([&](auto& list) { list.append(*this); });
|
|
}
|
|
|
|
VMObject::VMObject(size_t size)
|
|
: m_physical_pages(ceil_div(size, static_cast<size_t>(PAGE_SIZE)))
|
|
{
|
|
all_instances().with([&](auto& list) { list.append(*this); });
|
|
}
|
|
|
|
VMObject::~VMObject()
|
|
{
|
|
VERIFY(m_regions.is_empty());
|
|
}
|
|
|
|
}
|