From fda5c373b4d7e89bac8015380e43d9c31cc2d6cb Mon Sep 17 00:00:00 2001 From: Matthew Leach Date: Tue, 23 Dec 2025 19:18:10 +0000 Subject: [PATCH] sys_set_tid_address: finish implementation Now CLONE_CHILD_CLEARTID has been implemented properly, we can finish the implementation of `sys_set_tid_address`. --- src/arch/arm64/exceptions/syscall.rs | 2 +- src/process/threading/mod.rs | 12 ++++++------ 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/arch/arm64/exceptions/syscall.rs b/src/arch/arm64/exceptions/syscall.rs index 99b24fc..ca4c042 100644 --- a/src/arch/arm64/exceptions/syscall.rs +++ b/src/arch/arm64/exceptions/syscall.rs @@ -167,7 +167,7 @@ pub async fn handle_syscall() { 0x51 => sys_sync().await, 0x5d => sys_exit(arg1 as _).await, 0x5e => sys_exit_group(arg1 as _), - 0x60 => sys_set_tid_address(VA::from_value(arg1 as _)).await, + 0x60 => sys_set_tid_address(TUA::from_value(arg1 as _)), 0x62 => { sys_futex( TUA::from_value(arg1 as _), diff --git a/src/process/threading/mod.rs b/src/process/threading/mod.rs index 481a3f6..e679a57 100644 --- a/src/process/threading/mod.rs +++ b/src/process/threading/mod.rs @@ -4,17 +4,17 @@ use core::mem::size_of; use crate::sched::current_task; use libkernel::{ error::{KernelError, Result}, - memory::address::{TUA, VA}, + memory::address::TUA, }; pub mod futex; -pub async fn sys_set_tid_address(_tidptr: VA) -> Result { - let tid = current_task().tid; +pub fn sys_set_tid_address(tidptr: TUA) -> Result { + let task = current_task(); - // TODO: implement threading and this system call properly. For now, we just - // return the PID as the thread id. - Ok(tid.value() as _) + *task.child_tid_ptr.lock_save_irq() = Some(tidptr); + + Ok(task.tid.value() as _) } #[repr(C)]