mirror of
https://github.com/SerenityOS/serenity.git
synced 2025-01-24 18:32:28 -05:00
c1f8291ce4
Instead of panicking right away when we run out of physical pages, we now try to find a PurgeableVMObject with some volatile pages in it. If we find one, we purge that entire object and steal one of its pages. This makes it possible for the kernel to keep going instead of dying. Very cool. :^)
35 lines
1 KiB
C++
35 lines
1 KiB
C++
#pragma once
|
|
|
|
#include <Kernel/VM/AnonymousVMObject.h>
|
|
|
|
class PurgeableVMObject final : public AnonymousVMObject {
|
|
public:
|
|
virtual ~PurgeableVMObject() override;
|
|
|
|
static NonnullRefPtr<PurgeableVMObject> create_with_size(size_t);
|
|
virtual NonnullRefPtr<VMObject> clone() override;
|
|
|
|
int purge();
|
|
int purge_with_interrupts_disabled(Badge<MemoryManager>);
|
|
|
|
bool was_purged() const { return m_was_purged; }
|
|
void set_was_purged(bool b) { m_was_purged = b; }
|
|
|
|
bool is_volatile() const { return m_volatile; }
|
|
void set_volatile(bool b) { m_volatile = b; }
|
|
|
|
private:
|
|
explicit PurgeableVMObject(size_t);
|
|
explicit PurgeableVMObject(const PurgeableVMObject&);
|
|
|
|
int purge_impl();
|
|
|
|
PurgeableVMObject& operator=(const PurgeableVMObject&) = delete;
|
|
PurgeableVMObject& operator=(PurgeableVMObject&&) = delete;
|
|
PurgeableVMObject(PurgeableVMObject&&) = delete;
|
|
|
|
virtual bool is_purgeable() const override { return true; }
|
|
|
|
bool m_was_purged { false };
|
|
bool m_volatile { false };
|
|
};
|