Skip to content

Commit 37000c6

Browse files
committed
sync: add spin locks
1 parent 408fdfa commit 37000c6

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ authors = ["Yuekai Jia <equation618@gmail.com>"]
88

99
[dependencies]
1010
log = "0.4"
11-
spin = "0.9"
11+
spinlock = { path = "../../crates/spinlock" }
1212
memory_addr = { path = "../../crates/memory_addr" }
1313
allocator = { path = "../../crates/allocator" }
1414
axerror = { path = "../axerror" }

src/lib.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,23 +10,23 @@ mod page;
1010
use allocator::{AllocResult, BaseAllocator, ByteAllocator, PageAllocator};
1111
use allocator::{BitmapPageAllocator, BuddyByteAllocator};
1212
use core::alloc::{GlobalAlloc, Layout};
13-
use spin::Mutex;
13+
use spinlock::SpinNoIrq;
1414

1515
const PAGE_SIZE: usize = 0x1000;
1616
const MIN_HEAP_SIZE: usize = 0x4000; // 16 K
1717

1818
pub use page::GlobalPage;
1919

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

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

0 commit comments

Comments
 (0)