Skip to content

Commit 95514b9

Browse files
committed
feat: add naive slab allocator
1 parent 37000c6 commit 95514b9

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

src/lib.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,24 +8,24 @@ extern crate alloc;
88
mod page;
99

1010
use allocator::{AllocResult, BaseAllocator, ByteAllocator, PageAllocator};
11-
use allocator::{BitmapPageAllocator, BuddyByteAllocator};
11+
use allocator::{BitmapPageAllocator, SlabByteAllocator};
1212
use core::alloc::{GlobalAlloc, Layout};
1313
use spinlock::SpinNoIrq;
1414

1515
const PAGE_SIZE: usize = 0x1000;
16-
const MIN_HEAP_SIZE: usize = 0x4000; // 16 K
16+
const MIN_HEAP_SIZE: usize = 0x8000; // 32 K
1717

1818
pub use page::GlobalPage;
1919

2020
pub struct GlobalAllocator {
21-
balloc: SpinNoIrq<BuddyByteAllocator>, // TODO: use IRQ-disabled lock
21+
balloc: SpinNoIrq<SlabByteAllocator>,
2222
palloc: SpinNoIrq<BitmapPageAllocator<PAGE_SIZE>>,
2323
}
2424

2525
impl GlobalAllocator {
2626
pub const fn new() -> Self {
2727
Self {
28-
balloc: SpinNoIrq::new(BuddyByteAllocator::new()),
28+
balloc: SpinNoIrq::new(SlabByteAllocator::new()),
2929
palloc: SpinNoIrq::new(BitmapPageAllocator::new()),
3030
}
3131
}

0 commit comments

Comments
 (0)