From 4202bc3ba02e0ebf2892559657a292f185958bd3 Mon Sep 17 00:00:00 2001 From: 4lDO2 <4lDO2@protonmail.com> Date: Tue, 9 Jul 2024 16:13:26 +0200 Subject: [PATCH] WIP: add new-thread --- src/scheme/proc.rs | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/src/scheme/proc.rs b/src/scheme/proc.rs index b247a9fd79..3e4ab8ef33 100644 --- a/src/scheme/proc.rs +++ b/src/scheme/proc.rs @@ -524,8 +524,10 @@ impl KernelScheme for ProcScheme { let pid = if pid_str == "current" { OpenTy::Ctxt(context::current_cid()) - } else if pid_str == "new" { + } else if pid_str == "new" || pid_str == "new-child" { OpenTy::Ctxt(new_child()?) + } else if pid_str == "new-thread" { + OpenTy::Ctxt(new_thread()?) } else if !FULL { return Err(Error::new(EACCES)); } else { @@ -942,6 +944,13 @@ extern "C" fn clone_handler() { // usermode. } +fn new_thread() -> Result { + let current_process = process::current()?; + let new_context = Arc::clone(context::contexts_mut().spawn(true, current_process, clone_handler)?); + let cid = new_context.read().cid; + Ok(cid) +} + fn new_child() -> Result { let new_id = { let current_process_info = process::current()?.read().info; @@ -952,14 +961,7 @@ fn new_child() -> Result { })?; let new_context_lock = Arc::clone(context::contexts_mut().spawn(true, new_process, clone_handler)?); - - // (Signals are initially disabled.) - - let mut new_context = new_context_lock.write(); - - new_context.status = Status::HardBlocked { - reason: HardBlockedReason::NotYetStarted, - }; + let new_context = new_context_lock.read(); new_context.cid };