mirror of
https://github.com/rcore-os/rCore.git
synced 2024-11-22 16:16:16 +04:00
detach thread to auto recycle tid. fix #25
This commit is contained in:
parent
fc60d2cea2
commit
27f5c7b2e4
2
kernel/Cargo.lock
generated
2
kernel/Cargo.lock
generated
@ -426,7 +426,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "rcore-thread"
|
||||
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 = [
|
||||
"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)",
|
||||
|
@ -7,7 +7,8 @@ use crate::fs::INodeExt;
|
||||
pub fn sys_fork(tf: &TrapFrame) -> SysResult {
|
||||
let new_thread = current_thread().fork(tf);
|
||||
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);
|
||||
Ok(pid)
|
||||
}
|
||||
@ -48,6 +49,7 @@ pub fn sys_clone(
|
||||
let new_thread = current_thread().clone(tf, newsp, newtls, child_tid as usize);
|
||||
// FIXME: parent pid
|
||||
let tid = processor().manager().add(new_thread);
|
||||
processor().manager().detach(tid);
|
||||
info!("clone: {} -> {}", thread::current().id(), tid);
|
||||
*parent_tid_ref = tid as u32;
|
||||
*child_tid_ref = tid as u32;
|
||||
|
Loading…
Reference in New Issue
Block a user