Switch Context::grants to RwLock
This commit is contained in:
@@ -40,7 +40,7 @@ impl Scheme for MemoryScheme {
|
||||
let context_lock = contexts.current().ok_or(Error::new(ESRCH))?;
|
||||
let context = context_lock.read();
|
||||
|
||||
let mut grants = context.grants.lock();
|
||||
let mut grants = context.grants.write();
|
||||
|
||||
let region = grants.find_free_at(VirtualAddress::new(map.address), map.size, map.flags)?.round();
|
||||
|
||||
|
||||
@@ -90,7 +90,7 @@ pub fn resource() -> Result<Vec<u8>> {
|
||||
if let Some(ref sigstack) = context.sigstack {
|
||||
memory += sigstack.size();
|
||||
}
|
||||
for grant in context.grants.lock().iter() {
|
||||
for grant in context.grants.read().iter() {
|
||||
if grant.is_owned() {
|
||||
memory += grant.size();
|
||||
}
|
||||
|
||||
+2
-2
@@ -126,7 +126,7 @@ impl UserInner {
|
||||
let mut new_table = unsafe { InactivePageTable::from_address(context.arch.get_page_table()) };
|
||||
let mut temporary_page = TemporaryPage::new(Page::containing_address(VirtualAddress::new(crate::USER_TMP_GRANT_OFFSET)));
|
||||
|
||||
let mut grants = context.grants.lock();
|
||||
let mut grants = context.grants.write();
|
||||
|
||||
let from_address = round_down_pages(address);
|
||||
let offset = address - from_address;
|
||||
@@ -157,7 +157,7 @@ impl UserInner {
|
||||
let mut new_table = unsafe { InactivePageTable::from_address(context.arch.get_page_table()) };
|
||||
let mut temporary_page = TemporaryPage::new(Page::containing_address(VirtualAddress::new(crate::USER_TMP_GRANT_OFFSET)));
|
||||
|
||||
let mut grants = context.grants.lock();
|
||||
let mut grants = context.grants.write();
|
||||
|
||||
if let Some(region) = grants.contains(VirtualAddress::new(address)).map(Region::from) {
|
||||
grants.take(®ion).unwrap().unmap_inactive(&mut new_table, &mut temporary_page);
|
||||
|
||||
Reference in New Issue
Block a user