Add expr4 report and some trace for synctest

master
lcy1996 6 years ago
parent 65cd42028c
commit a8da42d521

@ -138,7 +138,7 @@ impl ProcessManager {
fn set_status(&self, pid: Pid, status: Status) {
let mut proc_lock = self.procs[pid].lock();
let mut proc = proc_lock.as_mut().expect("process not exist");
//info!("process {} {:?} -> {:?}", pid, proc.status, status);
trace!("process {} {:?} -> {:?}", pid, proc.status, status);
{ // limit the lifetime of scheduler
let mut scheduler = self.scheduler.lock();
match (&proc.status, &status) {

@ -68,6 +68,7 @@ impl Processor {
/// Called by process running on this Processor.
/// Yield and reschedule.
pub fn yield_now(&self) {
trace!("yield start");
let inner = self.inner();
unsafe {
inner.proc.as_mut().unwrap().1.switch_to(&mut *inner.loop_context);
@ -75,7 +76,7 @@ impl Processor {
}
pub fn pid(&self) -> Pid {
self.inner().proc.as_ref().unwrap().0
self.inner().proc.as_ref().expect("pid should not be none").0
}
pub fn context(&self) -> &Context {

@ -149,6 +149,7 @@ impl<T> JoinHandle<T> {
/// Waits for the associated thread to finish.
pub fn join(self) -> Result<T, ()> {
loop {
trace!("{} join", self.thread.pid);
match processor().manager().get_status(self.thread.pid) {
Some(Status::Exited(exit_code)) => {
processor().manager().wait_done(current().id(), self.thread.pid);

@ -0,0 +1,21 @@
# Rust OS lab 教学lab实验的制作 功能完善文档
## 0 添加注释
我们小组对于kernel以及crate中绝大部分重要函数都进行了注释,表明了参数@param,简要功能@brief以及返回值@retval.
此外对于部分代码中比较难以理解的部分和重点部分我们也进行了行内注释.
## 1 内存管理
@刘辰屹
## 2 进程管理与同步互斥
@陈秋昊
## 3 文件系统
@朱书聪
## 4 测试结果
### 4.1 用户程序测试结果
@刘辰屹 将最开始的RustOS版本与现在版本的用户程序运行结果进行对比
### 4.2 同步互斥测试结果
@陈秋昊

@ -43,6 +43,9 @@ pub fn shell() {
let layout = Layout::from_size_align(BUF_SIZE, 0x1000).unwrap();
let buf = unsafe{ slice::from_raw_parts_mut(alloc(layout), BUF_SIZE) };
// start interaction
use sync;
//sync::test::philosopher_using_mutex();
//sync::test::philosopher_using_monitor();
loop {
print!(">> ");

@ -64,6 +64,9 @@ pub mod arch;
pub fn kmain() -> ! {
info!("Come into kmain");
// sync::test::philosopher_using_mutex();
// sync::test::philosopher_using_monitor();
// sync::mpsc::test::test_all();
process::processor().run();
// thread::test::local_key();

@ -123,6 +123,9 @@ pub fn page_fault_handler(addr: usize) -> bool {
let id = memory_set_record().iter()
.position(|x| unsafe{(*(x.clone() as *mut MemorySet)).get_page_table_mut().token() == ActivePageTable::token()});
let mut mmsets = memory_set_record();
/*LAB3 EXERCISE 1: YOUR STUDENT NUMBER
* handle the frame deallocated
*/
match id {
Some(targetid) => {
info!("get id from memroy set recorder.");
@ -154,7 +157,7 @@ pub fn page_fault_handler(addr: usize) -> bool {
}
},
};
//////////////////////////////////////////////////////////////////////////////
// Handle copy on write (not being used now)

@ -92,6 +92,7 @@ fn philosopher(table: Arc<Table>) {
let handles: Vec<_> = philosophers.into_iter().map(|p| {
let table = table.clone();
trace!("philosopher start");
thread::spawn(move || {
for i in 0..5 {
@ -101,9 +102,10 @@ fn philosopher(table: Arc<Table>) {
}
})
}).collect();
trace!("philosopher starting finish");
for h in handles {
h.join().unwrap();
h.join().expect("join expects some value");
}
println!("philosophers dining end");
}

Loading…
Cancel
Save