mirror of
https://github.com/asterinas/asterinas.git
synced 2025-06-29 04:13:24 +00:00
Disable IRQ during page allocation
This commit is contained in:
committed by
Tate, Hongliang Tian
parent
846b3ba169
commit
c7b3a596dd
@ -65,7 +65,13 @@ pub(in crate::mm) static PAGE_ALLOCATOR: Once<SpinLock<CountingFrameAllocator>>
|
||||
///
|
||||
/// The metadata of the page is initialized with the given metadata.
|
||||
pub(crate) fn alloc_single<M: PageMeta>(metadata: M) -> Option<Page<M>> {
|
||||
PAGE_ALLOCATOR.get().unwrap().lock().alloc(1).map(|idx| {
|
||||
PAGE_ALLOCATOR
|
||||
.get()
|
||||
.unwrap()
|
||||
.disable_irq()
|
||||
.lock()
|
||||
.alloc(1)
|
||||
.map(|idx| {
|
||||
let paddr = idx * PAGE_SIZE;
|
||||
Page::from_unused(paddr, metadata)
|
||||
})
|
||||
@ -88,6 +94,7 @@ where
|
||||
PAGE_ALLOCATOR
|
||||
.get()
|
||||
.unwrap()
|
||||
.disable_irq()
|
||||
.lock()
|
||||
.alloc(len / PAGE_SIZE)
|
||||
.map(|start| {
|
||||
@ -113,7 +120,7 @@ where
|
||||
{
|
||||
assert!(len % PAGE_SIZE == 0);
|
||||
let nframes = len / PAGE_SIZE;
|
||||
let mut allocator = PAGE_ALLOCATOR.get().unwrap().lock();
|
||||
let mut allocator = PAGE_ALLOCATOR.get().unwrap().disable_irq().lock();
|
||||
let mut vector = Vec::new();
|
||||
for _ in 0..nframes {
|
||||
let paddr = allocator.alloc(1)? * PAGE_SIZE;
|
||||
|
Reference in New Issue
Block a user