From a145909998f397701bb7dd9551b339484a8eeafe Mon Sep 17 00:00:00 2001 From: lcy1996 <992195697@qq.com> Date: Mon, 5 Nov 2018 22:16:45 +0800 Subject: [PATCH] Fix compile error after merge for the new processor. --- kernel/src/fs.rs | 2 +- kernel/src/memory.rs | 22 +++------------------- kernel/src/process/context.rs | 12 ++++++++---- kernel/src/syscall.rs | 4 +++- 4 files changed, 15 insertions(+), 25 deletions(-) diff --git a/kernel/src/fs.rs b/kernel/src/fs.rs index 2915d6d..e648f01 100644 --- a/kernel/src/fs.rs +++ b/kernel/src/fs.rs @@ -53,7 +53,7 @@ pub fn shell() { use process::*; let len = file.borrow().read_at(0, &mut *buf).unwrap(); let context = ContextImpl::new_user(&buf[..len]); - memory_set_map_swappable(context.get_memory_set_mut()); + //memory_set_map_swappable(context.get_memory_set_mut()); let pid = processor().manager().add(context); //memory_set_map_swappable(processor().get_context_mut(pid).get_memory_set_mut()); processor().manager().wait(thread::current().id(), pid); diff --git a/kernel/src/memory.rs b/kernel/src/memory.rs index 0922240..236286b 100644 --- a/kernel/src/memory.rs +++ b/kernel/src/memory.rs @@ -7,14 +7,11 @@ use ucore_memory::{*, paging::PageTable}; use ucore_memory::cow::CowExt; pub use ucore_memory::memory_set::{MemoryArea, MemoryAttr, MemorySet as MemorySet_, Stack, InactivePageTable}; use ucore_memory::swap::*; -<<<<<<< HEAD -use process::{processor, PROCESSOR}; +//use process::{processor, PROCESSOR}; +use process::{process}; use sync::{SpinNoIrqLock, SpinNoIrq, MutexGuard}; use alloc::collections::VecDeque; -======= -use process::{processor, process}; ->>>>>>> 87506b000dc9a8f08c0040fee9570f5913bdd5b8 pub type MemorySet = MemorySet_; @@ -121,10 +118,7 @@ impl Drop for KernelStack { pub fn page_fault_handler(addr: usize) -> bool { info!("start handling swap in/out page fault"); unsafe { ACTIVE_TABLE_SWAP.force_unlock(); } -<<<<<<< HEAD - unsafe {PROCESSOR.try().unwrap().force_unlock();} - let mut temp_proc = processor(); debug!("active page table token in pg fault is {:x?}", ActivePageTable::token()); let id = memory_set_record().iter() .position(|x| unsafe{(*(x.clone() as *mut MemorySet)).get_page_table_mut().token() == ActivePageTable::token()}); @@ -140,28 +134,18 @@ pub fn page_fault_handler(addr: usize) -> bool { }, None => { debug!("get pt from processor()"); - let pt = temp_proc.current_context_mut().get_memory_set_mut().get_page_table_mut(); + let pt = process().get_memory_set_mut().get_page_table_mut(); if active_table_swap().page_fault_handler(pt as *mut InactivePageTable0, addr, true, || alloc_frame().unwrap()){ return true; } }, }; - // handle the swap in/out - //info!("start handling swap in/out page fault"); - //let mut temp_proc = processor(); - //let pt = temp_proc.current_context_mut().get_memory_set_mut().get_page_table_mut(); - //let pt = unsafe { (*(mmset_ptr.unwrap().clone() as *mut MemorySet)).get_page_table_mut() }; - // Handle copy on write (not being used now) unsafe { ACTIVE_TABLE.force_unlock(); } if active_table().page_fault_handler(addr, || alloc_frame().unwrap()){ -======= - let pt = process().get_memory_set_mut().get_page_table_mut(); - if active_table_swap().page_fault_handler(pt as *mut InactivePageTable0, addr, || alloc_frame().unwrap()){ ->>>>>>> 87506b000dc9a8f08c0040fee9570f5913bdd5b8 return true; } false diff --git a/kernel/src/process/context.rs b/kernel/src/process/context.rs index 68bed49..63fc2fd 100644 --- a/kernel/src/process/context.rs +++ b/kernel/src/process/context.rs @@ -115,14 +115,16 @@ impl ContextImpl { .position(|x| x.clone() == mmset_ptr).unwrap(); memory_set_record().remove(id); - Box::new(ContextImpl { + let mut ret = Box::new(ContextImpl { arch: unsafe { ArchContext::new_user_thread( entry_addr, user_stack_top - 8, kstack.top(), is32, memory_set.token()) }, memory_set, kstack, - }) + }); + memory_set_map_swappable(ret.get_memory_set_mut()); + ret } /// Fork @@ -159,11 +161,13 @@ impl ContextImpl { .position(|x| x.clone() == mmset_ptr).unwrap(); memory_set_record().remove(id); - Box::new(ContextImpl { + let mut ret = Box::new(ContextImpl { arch: unsafe { ArchContext::new_fork(tf, kstack.top(), memory_set.token()) }, memory_set, kstack, - }) + }); + memory_set_map_swappable(ret.get_memory_set_mut()); + ret } pub fn get_memory_set_mut(&mut self) -> &mut MemorySet { diff --git a/kernel/src/syscall.rs b/kernel/src/syscall.rs index c83acec..41ba1b4 100644 --- a/kernel/src/syscall.rs +++ b/kernel/src/syscall.rs @@ -8,6 +8,8 @@ use thread; use util; use process::context::memory_set_map_swappable; +use alloc::boxed::Box; +use process::context::*; /// 系统调用入口点 /// @@ -61,7 +63,7 @@ fn sys_close(fd: usize) -> i32 { /// Fork the current process. Return the child's PID. fn sys_fork(tf: &TrapFrame) -> i32 { let mut context = process().fork(tf); - memory_set_map_swappable(context.get_memory_set_mut()); + //memory_set_map_swappable(context.get_memory_set_mut()); let pid = processor().manager().add(context); Process::new_fork(pid, thread::current().id()); //memory_set_map_swappable(processor.get_context_mut(pid).get_memory_set_mut());