Fix a bug in context for smp

master
lcy1996 6 years ago
parent 67035ac556
commit b2fec2b16b

@ -139,14 +139,14 @@ impl<T: PageTable, M: SwapManager, S: Swapper> SwapExt<T, M, S> {
** @param alloc_frame: the function to alloc a free physical frame for once ** @param alloc_frame: the function to alloc a free physical frame for once
*/ */
pub unsafe fn remove_from_swappable<T2: InactivePageTable>(&mut self, pt: *mut T2, addr: VirtAddr, alloc_frame: impl FnOnce() -> PhysAddr){ pub unsafe fn remove_from_swappable<T2: InactivePageTable>(&mut self, pt: *mut T2, addr: VirtAddr, alloc_frame: impl FnOnce() -> PhysAddr){
info!("come into remove_from swappable"); //info!("come into remove_from swappable");
let Self {ref mut page_table, ref mut swap_manager, ref mut swapper} = self; let Self {ref mut page_table, ref mut swap_manager, ref mut swapper} = self;
let targetpt = &mut *(pt); let targetpt = &mut *(pt);
let pttoken = { let pttoken = {
debug!("the target page table token is {:x?}", targetpt.token()); info!("SET_UNSWAPPABLE: the target page table token is {:x?}, addr is {:x?}", targetpt.token(), addr);
targetpt.token() targetpt.token()
}; };
info!("try to change pagetable"); //info!("try to change pagetable");
targetpt.with(||{ targetpt.with(||{
let token = { let token = {
let entry = page_table.get_entry(addr).unwrap(); let entry = page_table.get_entry(addr).unwrap();

@ -112,10 +112,12 @@ impl ContextImpl {
} }
let kstack = KernelStack::new(); let kstack = KernelStack::new();
{
let id = memory_set_record().iter() let mut mmset_record = memory_set_record();
.position(|x| x.clone() == mmset_ptr).expect("id not exist"); let id = mmset_record.iter()
memory_set_record().remove(id); .position(|x| x.clone() == mmset_ptr).expect("id not exist");
mmset_record.remove(id);
}
let mut ret = Box::new(ContextImpl { let mut ret = Box::new(ContextImpl {
arch: unsafe { arch: unsafe {
@ -165,9 +167,13 @@ impl ContextImpl {
let kstack = KernelStack::new(); let kstack = KernelStack::new();
// remove the raw pointer for the memory set in memory_set_record // remove the raw pointer for the memory set in memory_set_record
let id = memory_set_record().iter() {
.position(|x| x.clone() == mmset_ptr).expect("id not exist"); let mut mmset_record = memory_set_record();
memory_set_record().remove(id); let id = mmset_record.iter()
.position(|x| x.clone() == mmset_ptr).expect("id not exist");
mmset_record.remove(id);
}
let mut ret = Box::new(ContextImpl { let mut ret = Box::new(ContextImpl {
arch: unsafe { ArchContext::new_fork(tf, kstack.top(), memory_set.token()) }, arch: unsafe { ArchContext::new_fork(tf, kstack.top(), memory_set.token()) },

Loading…
Cancel
Save