mirror of
https://github.com/asterinas/asterinas.git
synced 2025-06-24 01:43:22 +00:00
Fix the concurrency bug when multiple threads committing the same page
This commit is contained in:
committed by
Tate, Hongliang Tian
parent
840729d960
commit
cea4fd7777
@ -167,9 +167,9 @@ impl Pager for PageCacheManager {
|
||||
} else {
|
||||
Page::alloc_zero()?
|
||||
};
|
||||
let frame = page.frame().clone();
|
||||
self.pages.lock().put(idx, page);
|
||||
Ok(frame)
|
||||
|
||||
// If multiple threads commit the same page, only the first allocated page will be perserved.
|
||||
Ok(self.pages.lock().get_or_insert(idx, || page).frame.clone())
|
||||
}
|
||||
|
||||
fn update_page(&self, idx: usize) -> Result<()> {
|
||||
|
Reference in New Issue
Block a user