detach thread to auto recycle tid. fix #25

toolchain_update
WangRunji 6 years ago
parent fc60d2cea2
commit 27f5c7b2e4

2
kernel/Cargo.lock generated

@ -426,7 +426,7 @@ dependencies = [
[[package]] [[package]]
name = "rcore-thread" name = "rcore-thread"
version = "0.1.0" version = "0.1.0"
source = "git+https://github.com/rcore-os/rcore-thread#7236bfd2e2bde673773214739695bb2925a77ae5" source = "git+https://github.com/rcore-os/rcore-thread#fd972c7e3aa2b7618f625f143655c16adfd2ca78"
dependencies = [ dependencies = [
"deque 0.3.2 (git+https://github.com/rcore-os/deque.git?branch=no_std)", "deque 0.3.2 (git+https://github.com/rcore-os/deque.git?branch=no_std)",
"log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)",

@ -7,7 +7,8 @@ use crate::fs::INodeExt;
pub fn sys_fork(tf: &TrapFrame) -> SysResult { pub fn sys_fork(tf: &TrapFrame) -> SysResult {
let new_thread = current_thread().fork(tf); let new_thread = current_thread().fork(tf);
let pid = new_thread.proc.lock().pid.get(); let pid = new_thread.proc.lock().pid.get();
processor().manager().add(new_thread); let tid = processor().manager().add(new_thread);
processor().manager().detach(tid);
info!("fork: {} -> {}", thread::current().id(), pid); info!("fork: {} -> {}", thread::current().id(), pid);
Ok(pid) Ok(pid)
} }
@ -48,6 +49,7 @@ pub fn sys_clone(
let new_thread = current_thread().clone(tf, newsp, newtls, child_tid as usize); let new_thread = current_thread().clone(tf, newsp, newtls, child_tid as usize);
// FIXME: parent pid // FIXME: parent pid
let tid = processor().manager().add(new_thread); let tid = processor().manager().add(new_thread);
processor().manager().detach(tid);
info!("clone: {} -> {}", thread::current().id(), tid); info!("clone: {} -> {}", thread::current().id(), tid);
*parent_tid_ref = tid as u32; *parent_tid_ref = tid as u32;
*child_tid_ref = tid as u32; *child_tid_ref = tid as u32;

Loading…
Cancel
Save