From 61849150573a089135f26b63b4be123ed30102c0 Mon Sep 17 00:00:00 2001 From: lhw Date: Sun, 24 Nov 2024 20:15:27 +0800 Subject: [PATCH] add loopback --- api/ruxos_posix_api/src/imp/pipe.rs | 2 +- api/ruxos_posix_api/src/imp/pthread/mod.rs | 2 +- api/ruxos_posix_api/src/imp/task.rs | 4 ++-- api/ruxos_posix_api/src/lib.rs | 4 +++- modules/ruxhal/src/arch/x86_64/mod.rs | 2 +- modules/ruxtask/src/api.rs | 10 ++++++---- modules/ruxtask/src/task.rs | 12 +++++------- ulib/ruxmusl/src/aarch64/mod.rs | 4 +--- 8 files changed, 20 insertions(+), 20 deletions(-) diff --git a/api/ruxos_posix_api/src/imp/pipe.rs b/api/ruxos_posix_api/src/imp/pipe.rs index 6fb29a04c..98110dbf7 100644 --- a/api/ruxos_posix_api/src/imp/pipe.rs +++ b/api/ruxos_posix_api/src/imp/pipe.rs @@ -7,7 +7,7 @@ * See the Mulan PSL v2 for more details. */ -use alloc::sync::{Weak, Arc}; +use alloc::sync::{Arc, Weak}; use core::ffi::c_int; use axerrno::{LinuxError, LinuxResult}; diff --git a/api/ruxos_posix_api/src/imp/pthread/mod.rs b/api/ruxos_posix_api/src/imp/pthread/mod.rs index 405d5b13a..da2694ff8 100644 --- a/api/ruxos_posix_api/src/imp/pthread/mod.rs +++ b/api/ruxos_posix_api/src/imp/pthread/mod.rs @@ -231,7 +231,7 @@ pub fn sys_exit_group(status: c_int) -> ! { debug!("sys_exit_group <= status: {:#?}", status); // TODO: exit all threads, send signal to all threads - + // drop all file opened by current task current().fs.lock().as_mut().unwrap().close_all_files(); diff --git a/api/ruxos_posix_api/src/imp/task.rs b/api/ruxos_posix_api/src/imp/task.rs index 17d365c83..ae07be44b 100644 --- a/api/ruxos_posix_api/src/imp/task.rs +++ b/api/ruxos_posix_api/src/imp/task.rs @@ -77,7 +77,7 @@ pub fn sys_wait4( // lower 8 bits of exit_code is the signal number, while upper 8 bits of exit_code is the exit status // according to "bits/waitstatus.h" in glibc source code. // TODO: add signal number to wstatus - wstatus.write(task.exit_code()<<8); + wstatus.write(task.exit_code() << 8); } process_map.remove(&(pid as u64)); return pid; @@ -108,7 +108,7 @@ pub fn sys_wait4( // lower 8 bits of exit_code is the signal number, while upper 8 bits of exit_code is the exit status // according to "bits/waitstatus.h" in glibc source code. // TODO: add signal number to wstatus - wstatus.write(task.exit_code()<<8); + wstatus.write(task.exit_code() << 8); } let _ = to_remove.insert(*child_pid); break; diff --git a/api/ruxos_posix_api/src/lib.rs b/api/ruxos_posix_api/src/lib.rs index c13cbaded..f7d50620e 100644 --- a/api/ruxos_posix_api/src/lib.rs +++ b/api/ruxos_posix_api/src/lib.rs @@ -120,7 +120,9 @@ pub use imp::pthread::sys_clone; #[cfg(all(feature = "multitask", feature = "musl"))] pub use imp::pthread::sys_set_tid_address; #[cfg(feature = "multitask")] -pub use imp::pthread::{sys_pthread_create, sys_pthread_exit, sys_exit_group, sys_pthread_join, sys_pthread_self}; +pub use imp::pthread::{ + sys_exit_group, sys_pthread_create, sys_pthread_exit, sys_pthread_join, sys_pthread_self, +}; #[cfg(feature = "fs")] pub use imp::execve::sys_execve; diff --git a/modules/ruxhal/src/arch/x86_64/mod.rs b/modules/ruxhal/src/arch/x86_64/mod.rs index ea97eee5c..0abb0fef4 100644 --- a/modules/ruxhal/src/arch/x86_64/mod.rs +++ b/modules/ruxhal/src/arch/x86_64/mod.rs @@ -235,7 +235,7 @@ pub unsafe fn init_syscall_entry() { .has_syscall_sysret()); x86_64::registers::model_specific::LStar::write(x86_64::VirtAddr::new( - x86_syscall_entry as usize, + x86_syscall_entry as u64, )); x86_64::registers::model_specific::Efer::update(|efer| { efer.insert( diff --git a/modules/ruxtask/src/api.rs b/modules/ruxtask/src/api.rs index 2ae4d1d4b..818ca3e68 100644 --- a/modules/ruxtask/src/api.rs +++ b/modules/ruxtask/src/api.rs @@ -138,12 +138,14 @@ pub fn fork_task() -> Option { // Judge whether the parent process is blocked, if yes, add it to the blocking queue of the child process if current().id().as_u64() == current_id { RUN_QUEUE.lock().add_task(children_process.clone()); - + return Some(children_process); } - - unsafe {RUN_QUEUE.force_unlock(); } - + + unsafe { + RUN_QUEUE.force_unlock(); + } + // should not drop the children_process here, because it will be taken in the parent process // and dropped in the parent process let _ = ManuallyDrop::new(children_process); diff --git a/modules/ruxtask/src/task.rs b/modules/ruxtask/src/task.rs index d84b72c89..cc1a45d20 100644 --- a/modules/ruxtask/src/task.rs +++ b/modules/ruxtask/src/task.rs @@ -629,14 +629,12 @@ impl TaskInner { let tls = VirtAddr::from(t.tls.tls_ptr() as usize); #[cfg(not(feature = "tls"))] let tls = VirtAddr::from(0); - + debug!("new idle task: {}", t.id_name()); - t.ctx.get_mut().init( - task_entry as usize, - idle_kstack.top(), - tls, - ); - + t.ctx + .get_mut() + .init(task_entry as usize, idle_kstack.top(), tls); + let task_ref = Arc::new(AxTask::new(t)); task_ref diff --git a/ulib/ruxmusl/src/aarch64/mod.rs b/ulib/ruxmusl/src/aarch64/mod.rs index 12f3ae009..d2e38e982 100644 --- a/ulib/ruxmusl/src/aarch64/mod.rs +++ b/ulib/ruxmusl/src/aarch64/mod.rs @@ -201,9 +201,7 @@ pub fn syscall(syscall_id: SyscallId, args: [usize; 6]) -> isize { SyscallId::EXIT => { ruxos_posix_api::sys_pthread_exit(args[0] as *mut core::ffi::c_void) as _ } - SyscallId::EXIT_GROUP => { - ruxos_posix_api::sys_exit_group(args[0] as c_int) - } + SyscallId::EXIT_GROUP => ruxos_posix_api::sys_exit_group(args[0] as c_int), #[cfg(feature = "multitask")] SyscallId::SET_TID_ADDRESS => ruxos_posix_api::sys_set_tid_address(args[0]) as _, #[cfg(feature = "multitask")]