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
*/
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 targetpt = &mut *(pt);
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()
};
info!("try to change pagetable");
//info!("try to change pagetable");
targetpt.with(||{
let token = {
let entry = page_table.get_entry(addr).unwrap();

@ -112,10 +112,12 @@ impl ContextImpl {
}
let kstack = KernelStack::new();
let id = memory_set_record().iter()
.position(|x| x.clone() == mmset_ptr).expect("id not exist");
memory_set_record().remove(id);
{
let mut mmset_record = memory_set_record();
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 {
arch: unsafe {
@ -165,9 +167,13 @@ impl ContextImpl {
let kstack = KernelStack::new();
// 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");
memory_set_record().remove(id);
{
let mut mmset_record = memory_set_record();
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 {
arch: unsafe { ArchContext::new_fork(tf, kstack.top(), memory_set.token()) },

Loading…
Cancel
Save