1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-19 00:35:06 +00:00

Kernel: Add a /proc/all process table dump.

This will be useful for implementing some process-related utilities.
This commit is contained in:
Andreas Kling 2019-02-03 18:53:18 +01:00
parent dddd0e7b03
commit b51031bb54
5 changed files with 83 additions and 4 deletions

View file

@ -327,7 +327,7 @@ int Process::do_exec(const String& path, Vector<String>&& arguments, Vector<Stri
auto vmo = VMObject::create_file_backed(descriptor->inode(), descriptor->metadata().size);
vmo->set_name(descriptor->absolute_path());
auto* region = allocate_region_with_vmo(LinearAddress(), descriptor->metadata().size, vmo.copy_ref(), 0, "helper", true, false);
RetainPtr<Region> region = allocate_region_with_vmo(LinearAddress(), descriptor->metadata().size, vmo.copy_ref(), 0, "helper", true, false);
// FIXME: Should we consider doing on-demand paging here? Is it actually useful?
bool success = region->page_in();
@ -374,6 +374,8 @@ int Process::do_exec(const String& path, Vector<String>&& arguments, Vector<Stri
}
}
m_regions.append(move(region));
m_signal_stack_kernel_region = nullptr;
m_signal_stack_user_region = nullptr;
m_display_framebuffer_region = nullptr;
@ -2170,3 +2172,35 @@ void Process::die()
m_fds.clear();
destroy_all_windows();
}
size_t Process::amount_virtual() const
{
size_t amount = 0;
for (auto& region : m_regions) {
amount += region->size();
}
return amount;
}
size_t Process::amount_resident() const
{
// FIXME: This will double count if multiple regions use the same physical page.
size_t amount = 0;
for (auto& region : m_regions) {
amount += region->amount_resident();
}
return amount;
}
size_t Process::amount_shared() const
{
// FIXME: This will double count if multiple regions use the same physical page.
// FIXME: It doesn't work at the moment, since it relies on PhysicalPage retain counts,
// and each PhysicalPage is only retained by its VMObject. This needs to be refactored
// so that every Region contributes +1 retain to each of its PhysicalPages.
size_t amount = 0;
for (auto& region : m_regions) {
amount += region->amount_shared();
}
return amount;
}