Kernel: We add FixedWidthAllocators on demand

On SYS_ALLOC we will add a new FixedWidthAllocator if the old ones
are already full or we don't have one with proper size. This allows
arbitary number of allocations as long as you have enough memory
available :)

Next I will be writing a general allocator for allocations larger
than 4096 bytes which should make SYS_ALLOC syscall complete :)
This commit is contained in:
Bananymous
2023-05-07 23:57:01 +03:00
parent 05046d6e93
commit b0ec0f1a1a
5 changed files with 77 additions and 27 deletions

View File

@@ -21,6 +21,9 @@ namespace Kernel
uint32_t allocation_size() const { return m_allocation_size; }
uint32_t allocations() const { return m_allocations; }
uint32_t max_allocations() const;
private:
struct node
{
@@ -44,7 +47,7 @@ namespace Kernel
node* m_free_list { nullptr };
node* m_used_list { nullptr };
uint32_t m_allocated { 0 };
uint32_t m_allocations { 0 };
};
}

View File

@@ -94,7 +94,7 @@ namespace Kernel
BAN::String m_working_directory;
BAN::Vector<Thread*> m_threads;
BAN::Vector<FixedWidthAllocator> m_fixed_width_allocators;
BAN::LinkedList<FixedWidthAllocator> m_fixed_width_allocators;
MMU* m_mmu { nullptr };
TTY* m_tty { nullptr };