Skip to content

Commit

Permalink
fix bugs of raii
Browse files Browse the repository at this point in the history
  • Loading branch information
ToniXWD committed Oct 30, 2023
1 parent 06813e0 commit ee2999e
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions os/src/mm/memory_set.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ lazy_static! {
pub struct MemorySet {
page_table: PageTable,
areas: Vec<MapArea>,
map_tree: BTreeMap<VirtPageNum, FrameTracker>,
}

impl MemorySet {
Expand All @@ -45,6 +46,7 @@ impl MemorySet {
Self {
page_table: PageTable::new(),
areas: Vec::new(),
map_tree: BTreeMap::new(),
}
}
/// Get the page table token
Expand Down Expand Up @@ -308,6 +310,7 @@ impl MemorySet {
}
if let Some(ppn) = frame_alloc() {
self.page_table.map(va_start, ppn.ppn, flags);
self.map_tree.insert(va_start, ppn);
} else {
return -1;
}
Expand Down Expand Up @@ -339,6 +342,7 @@ impl MemorySet {
return -1;
}
self.page_table.unmap(va_start);
self.map_tree.remove(&va_start);
va_start.step();
}
0
Expand Down

0 comments on commit ee2999e

Please sign in to comment.