Skip to content

Commit

Permalink
fix fork bug
Browse files Browse the repository at this point in the history
  • Loading branch information
刘丰源 committed Feb 12, 2020
1 parent b8e1bfd commit 5461f93
Show file tree
Hide file tree
Showing 5 changed files with 5 additions and 4 deletions.
1 change: 1 addition & 0 deletions os/src/interrupt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ fn super_timer() {
clock_set_next_event();
tick();
}

fn page_fault(tf: &mut TrapFrame) {
println!(
"{:?} va = {:#x} instruction = {:#x}",
Expand Down
2 changes: 1 addition & 1 deletion os/src/process/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,6 @@ pub fn add_thread(thread: Box<Thread>) -> usize {
CPU.add_thread(thread)
}

pub fn current_thread() -> Box<Thread> {
pub fn current_thread() -> &'static Box<Thread> {
CPU.current_thread()
}
4 changes: 2 additions & 2 deletions os/src/process/processor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ impl Processor {
self.inner().current.as_mut().unwrap().0 as usize
}

pub fn current_thread(&self) -> Box<Thread> {
self.inner().current.as_ref().unwrap().1.clone()
pub fn current_thread(&self) -> &Box<Thread> {
&self.inner().current.as_mut().unwrap().1
}
}
1 change: 0 additions & 1 deletion os/src/process/structs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,6 @@ impl Thread {
}
}

#[derive(Clone)]
pub struct KernelStack(usize);

impl KernelStack {
Expand Down
1 change: 1 addition & 0 deletions usr/rust/src/bin/fork.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ use user::syscall::sys_fork;

#[no_mangle]
pub fn main() -> usize {
let tid = sys_fork();
let tid = sys_fork();
if tid == 0 {
println!("I am child");
Expand Down

0 comments on commit 5461f93

Please sign in to comment.