Optimize the latency of lat-sig-install

This commit is contained in:
Jianfeng Jiang
2024-08-30 09:12:07 +00:00
committed by Tate, Hongliang Tian
parent cf9c71119a
commit fb718fd440
17 changed files with 148 additions and 99 deletions

View File

@ -55,7 +55,7 @@ impl Thread {
/// # Panics
///
/// This method panics if the task is not a thread.
pub fn borrow_from_task(task: &Arc<Task>) -> &Arc<Self> {
pub fn borrow_from_task(task: &Task) -> &Arc<Self> {
task.data().downcast_ref::<Arc<Thread>>().unwrap()
}

View File

@ -8,6 +8,7 @@ use ostd::{
use super::Thread;
use crate::{
cpu::LinuxAbi,
get_current_userspace,
prelude::*,
process::{posix_thread::PosixThreadExt, signal::handle_pending_signal},
syscall::handle_syscall,
@ -46,7 +47,7 @@ pub fn create_new_user_task(user_space: Arc<UserSpace>, thread_ref: Arc<Thread>)
// Make sure the store operation completes before the clone call returns control to user space
// in the child process.
if is_userspace_vaddr(child_tid_ptr) {
CurrentUserSpace::get()
get_current_userspace!()
.write_val(child_tid_ptr, &current_posix_thread.tid())
.unwrap();
}
@ -73,12 +74,12 @@ pub fn create_new_user_task(user_space: Arc<UserSpace>, thread_ref: Arc<Thread>)
if current_thread.status().is_exited() {
break;
}
handle_pending_signal(user_ctx, &current_thread).unwrap();
handle_pending_signal(user_ctx, &ctx).unwrap();
// If current is suspended, wait for a signal to wake up self
while current_thread.status().is_stopped() {
Thread::yield_now();
debug!("{} is suspended.", current_posix_thread.tid());
handle_pending_signal(user_ctx, &current_thread).unwrap();
handle_pending_signal(user_ctx, &ctx).unwrap();
}
if current_thread.status().is_exited() {
debug!("exit due to signal");