Kernel: fork() now copies allocations through FixedWidthAllocator

This commit is contained in:
Bananymous
2023-05-28 21:34:35 +03:00
parent ec73db0057
commit 09666adc53
4 changed files with 121 additions and 40 deletions

View File

@@ -15,6 +15,8 @@ namespace Kernel
FixedWidthAllocator(MMU&, uint32_t);
~FixedWidthAllocator();
BAN::ErrorOr<FixedWidthAllocator*> clone(MMU&);
vaddr_t allocate();
bool deallocate(vaddr_t);
@@ -24,6 +26,8 @@ namespace Kernel
uint32_t max_allocations() const;
private:
bool allocate_page_if_needed(vaddr_t, uint8_t flags);
struct node
{
node* prev { nullptr };
@@ -34,6 +38,9 @@ namespace Kernel
node* node_from_address(vaddr_t) const;
void allocate_page_for_node_if_needed(const node*);
void allocate_node(node*);
void deallocate_node(node*);
private:
static constexpr uint32_t m_min_allocation_size = 16;