1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 08:48:11 +00:00

Kernel: Make Region single-owner instead of ref-counted

This simplifies the ownership model and makes Region easier to reason
about. Userspace Regions are now primarily kept by Process::m_regions.

Kernel Regions are kept in various OwnPtr<Regions>'s.

Regions now only ever get unmapped when they are destroyed.
This commit is contained in:
Andreas Kling 2019-09-27 14:19:07 +02:00
parent 7a7f6a24e9
commit 7f9a33dba1
9 changed files with 44 additions and 41 deletions

View file

@ -50,7 +50,7 @@ Region::~Region()
MM.unregister_region(*this);
}
NonnullRefPtr<Region> Region::clone()
NonnullOwnPtr<Region> Region::clone()
{
ASSERT(current);
@ -123,30 +123,30 @@ size_t Region::amount_shared() const
return bytes;
}
NonnullRefPtr<Region> Region::create_user_accessible(const Range& range, const StringView& name, u8 access, bool cow)
NonnullOwnPtr<Region> Region::create_user_accessible(const Range& range, const StringView& name, u8 access, bool cow)
{
auto region = adopt(*new Region(range, name, access, cow));
auto region = make<Region>(range, name, access, cow);
region->m_user_accessible = true;
return region;
}
NonnullRefPtr<Region> Region::create_user_accessible(const Range& range, NonnullRefPtr<VMObject> vmobject, size_t offset_in_vmobject, const StringView& name, u8 access, bool cow)
NonnullOwnPtr<Region> Region::create_user_accessible(const Range& range, NonnullRefPtr<VMObject> vmobject, size_t offset_in_vmobject, const StringView& name, u8 access, bool cow)
{
auto region = adopt(*new Region(range, move(vmobject), offset_in_vmobject, name, access, cow));
auto region = make<Region>(range, move(vmobject), offset_in_vmobject, name, access, cow);
region->m_user_accessible = true;
return region;
}
NonnullRefPtr<Region> Region::create_user_accessible(const Range& range, NonnullRefPtr<Inode> inode, const StringView& name, u8 access, bool cow)
NonnullOwnPtr<Region> Region::create_user_accessible(const Range& range, NonnullRefPtr<Inode> inode, const StringView& name, u8 access, bool cow)
{
auto region = adopt(*new Region(range, move(inode), name, access, cow));
auto region = make<Region>(range, move(inode), name, access, cow);
region->m_user_accessible = true;
return region;
}
NonnullRefPtr<Region> Region::create_kernel_only(const Range& range, const StringView& name, u8 access, bool cow)
NonnullOwnPtr<Region> Region::create_kernel_only(const Range& range, const StringView& name, u8 access, bool cow)
{
auto region = adopt(*new Region(range, name, access, cow));
auto region = make<Region>(range, name, access, cow);
region->m_user_accessible = false;
return region;
}