mirror of
https://github.com/asterinas/asterinas.git
synced 2025-06-18 12:06:43 +00:00
Replace most of the current_thread!
usages via Context
This commit is contained in:
committed by
Tate, Hongliang Tian
parent
9200538175
commit
8cf7063150
@ -11,7 +11,7 @@ use crate::{
|
|||||||
utils::CreationFlags,
|
utils::CreationFlags,
|
||||||
},
|
},
|
||||||
prelude::*,
|
prelude::*,
|
||||||
process::{posix_thread::PosixThreadExt, signal::sig_mask::SigMask},
|
process::signal::sig_mask::SigMask,
|
||||||
};
|
};
|
||||||
|
|
||||||
pub fn sys_epoll_create(size: i32, ctx: &Context) -> Result<SyscallReturn> {
|
pub fn sys_epoll_create(size: i32, ctx: &Context) -> Result<SyscallReturn> {
|
||||||
@ -152,29 +152,26 @@ pub fn sys_epoll_wait(
|
|||||||
Ok(SyscallReturn::Return(epoll_events.len() as _))
|
Ok(SyscallReturn::Return(epoll_events.len() as _))
|
||||||
}
|
}
|
||||||
|
|
||||||
fn set_signal_mask(set_ptr: Vaddr) -> Result<SigMask> {
|
fn set_signal_mask(set_ptr: Vaddr, ctx: &Context) -> Result<SigMask> {
|
||||||
let new_mask: Option<SigMask> = if set_ptr != 0 {
|
let new_mask: Option<SigMask> = if set_ptr != 0 {
|
||||||
Some(CurrentUserSpace::get().read_val::<u64>(set_ptr)?.into())
|
Some(CurrentUserSpace::get().read_val::<u64>(set_ptr)?.into())
|
||||||
} else {
|
} else {
|
||||||
None
|
None
|
||||||
};
|
};
|
||||||
|
|
||||||
let current_thread = current_thread!();
|
let old_sig_mask_value = ctx.posix_thread.sig_mask().load(Ordering::Relaxed);
|
||||||
let posix_thread = current_thread.as_posix_thread().unwrap();
|
|
||||||
|
|
||||||
let old_sig_mask_value = posix_thread.sig_mask().load(Ordering::Relaxed);
|
|
||||||
|
|
||||||
if let Some(new_mask) = new_mask {
|
if let Some(new_mask) = new_mask {
|
||||||
posix_thread.sig_mask().store(new_mask, Ordering::Relaxed);
|
ctx.posix_thread
|
||||||
|
.sig_mask()
|
||||||
|
.store(new_mask, Ordering::Relaxed);
|
||||||
}
|
}
|
||||||
|
|
||||||
Ok(old_sig_mask_value)
|
Ok(old_sig_mask_value)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn restore_signal_mask(sig_mask_val: SigMask) {
|
fn restore_signal_mask(sig_mask_val: SigMask, ctx: &Context) {
|
||||||
let current_thread = current_thread!();
|
ctx.posix_thread
|
||||||
let posix_thread = current_thread.as_posix_thread().unwrap();
|
|
||||||
posix_thread
|
|
||||||
.sig_mask()
|
.sig_mask()
|
||||||
.store(sig_mask_val, Ordering::Relaxed);
|
.store(sig_mask_val, Ordering::Relaxed);
|
||||||
}
|
}
|
||||||
@ -197,16 +194,16 @@ pub fn sys_epoll_pwait(
|
|||||||
error!("sigset size is not equal to 8");
|
error!("sigset size is not equal to 8");
|
||||||
}
|
}
|
||||||
|
|
||||||
let old_sig_mask_value = set_signal_mask(sigmask)?;
|
let old_sig_mask_value = set_signal_mask(sigmask, ctx)?;
|
||||||
|
|
||||||
let ready_events = match do_epoll_wait(epfd, max_events, timeout, ctx) {
|
let ready_events = match do_epoll_wait(epfd, max_events, timeout, ctx) {
|
||||||
Ok(events) => {
|
Ok(events) => {
|
||||||
restore_signal_mask(old_sig_mask_value);
|
restore_signal_mask(old_sig_mask_value, ctx);
|
||||||
events
|
events
|
||||||
}
|
}
|
||||||
Err(e) => {
|
Err(e) => {
|
||||||
// Restore the signal mask even if an error occurs
|
// Restore the signal mask even if an error occurs
|
||||||
restore_signal_mask(old_sig_mask_value);
|
restore_signal_mask(old_sig_mask_value, ctx);
|
||||||
return Err(e);
|
return Err(e);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -16,7 +16,7 @@ pub fn sys_futex(
|
|||||||
utime_addr: u64,
|
utime_addr: u64,
|
||||||
futex_new_addr: u64,
|
futex_new_addr: u64,
|
||||||
bitset: u64,
|
bitset: u64,
|
||||||
_ctx: &Context,
|
ctx: &Context,
|
||||||
) -> Result<SyscallReturn> {
|
) -> Result<SyscallReturn> {
|
||||||
// FIXME: we current ignore futex flags
|
// FIXME: we current ignore futex flags
|
||||||
let (futex_op, futex_flags) = futex_op_and_flags_from_u32(futex_op as _).unwrap();
|
let (futex_op, futex_flags) = futex_op_and_flags_from_u32(futex_op as _).unwrap();
|
||||||
@ -72,6 +72,6 @@ pub fn sys_futex(
|
|||||||
}
|
}
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
||||||
debug!("futex returns, tid= {} ", current_thread!().tid());
|
debug!("futex returns, tid= {} ", ctx.thread.tid());
|
||||||
Ok(SyscallReturn::Return(res as _))
|
Ok(SyscallReturn::Return(res as _))
|
||||||
}
|
}
|
||||||
|
@ -3,8 +3,7 @@
|
|||||||
use super::SyscallReturn;
|
use super::SyscallReturn;
|
||||||
use crate::prelude::*;
|
use crate::prelude::*;
|
||||||
|
|
||||||
pub fn sys_gettid(_ctx: &Context) -> Result<SyscallReturn> {
|
pub fn sys_gettid(ctx: &Context) -> Result<SyscallReturn> {
|
||||||
let current_thread = current_thread!();
|
let tid = ctx.thread.tid();
|
||||||
let tid = current_thread.tid();
|
|
||||||
Ok(SyscallReturn::Return(tid as _))
|
Ok(SyscallReturn::Return(tid as _))
|
||||||
}
|
}
|
||||||
|
@ -3,10 +3,7 @@
|
|||||||
use super::SyscallReturn;
|
use super::SyscallReturn;
|
||||||
use crate::{
|
use crate::{
|
||||||
prelude::*,
|
prelude::*,
|
||||||
process::{
|
process::{posix_thread::MAX_THREAD_NAME_LEN, signal::sig_num::SigNum},
|
||||||
posix_thread::{PosixThreadExt, MAX_THREAD_NAME_LEN},
|
|
||||||
signal::sig_num::SigNum,
|
|
||||||
},
|
|
||||||
};
|
};
|
||||||
|
|
||||||
pub fn sys_prctl(
|
pub fn sys_prctl(
|
||||||
@ -19,8 +16,6 @@ pub fn sys_prctl(
|
|||||||
) -> Result<SyscallReturn> {
|
) -> Result<SyscallReturn> {
|
||||||
let prctl_cmd = PrctlCmd::from_args(option, arg2, arg3, arg4, arg5)?;
|
let prctl_cmd = PrctlCmd::from_args(option, arg2, arg3, arg4, arg5)?;
|
||||||
debug!("prctl cmd = {:x?}", prctl_cmd);
|
debug!("prctl cmd = {:x?}", prctl_cmd);
|
||||||
let current_thread = current_thread!();
|
|
||||||
let posix_thread = current_thread.as_posix_thread().unwrap();
|
|
||||||
match prctl_cmd {
|
match prctl_cmd {
|
||||||
PrctlCmd::PR_SET_PDEATHSIG(signum) => {
|
PrctlCmd::PR_SET_PDEATHSIG(signum) => {
|
||||||
ctx.process.set_parent_death_signal(signum);
|
ctx.process.set_parent_death_signal(signum);
|
||||||
@ -47,7 +42,7 @@ pub fn sys_prctl(
|
|||||||
// TODO: implement coredump
|
// TODO: implement coredump
|
||||||
}
|
}
|
||||||
PrctlCmd::PR_GET_NAME(write_to_addr) => {
|
PrctlCmd::PR_GET_NAME(write_to_addr) => {
|
||||||
let thread_name = posix_thread.thread_name().lock();
|
let thread_name = ctx.posix_thread.thread_name().lock();
|
||||||
if let Some(thread_name) = &*thread_name {
|
if let Some(thread_name) = &*thread_name {
|
||||||
if let Some(thread_name) = thread_name.name()? {
|
if let Some(thread_name) = thread_name.name()? {
|
||||||
CurrentUserSpace::get().write_bytes(
|
CurrentUserSpace::get().write_bytes(
|
||||||
@ -58,7 +53,7 @@ pub fn sys_prctl(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
PrctlCmd::PR_SET_NAME(read_addr) => {
|
PrctlCmd::PR_SET_NAME(read_addr) => {
|
||||||
let mut thread_name = posix_thread.thread_name().lock();
|
let mut thread_name = ctx.posix_thread.thread_name().lock();
|
||||||
if let Some(thread_name) = &mut *thread_name {
|
if let Some(thread_name) = &mut *thread_name {
|
||||||
let new_thread_name =
|
let new_thread_name =
|
||||||
CurrentUserSpace::get().read_cstring(read_addr, MAX_THREAD_NAME_LEN)?;
|
CurrentUserSpace::get().read_cstring(read_addr, MAX_THREAD_NAME_LEN)?;
|
||||||
|
@ -3,12 +3,12 @@
|
|||||||
use core::sync::atomic::Ordering;
|
use core::sync::atomic::Ordering;
|
||||||
|
|
||||||
use super::SyscallReturn;
|
use super::SyscallReturn;
|
||||||
use crate::{prelude::*, process::posix_thread::PosixThreadExt};
|
use crate::prelude::*;
|
||||||
|
|
||||||
pub fn sys_rt_sigpending(
|
pub fn sys_rt_sigpending(
|
||||||
u_set_ptr: Vaddr,
|
u_set_ptr: Vaddr,
|
||||||
sigset_size: usize,
|
sigset_size: usize,
|
||||||
_ctx: &Context,
|
ctx: &Context,
|
||||||
) -> Result<SyscallReturn> {
|
) -> Result<SyscallReturn> {
|
||||||
debug!(
|
debug!(
|
||||||
"u_set_ptr = 0x{:x}, sigset_size = {}",
|
"u_set_ptr = 0x{:x}, sigset_size = {}",
|
||||||
@ -17,17 +17,14 @@ pub fn sys_rt_sigpending(
|
|||||||
if sigset_size != 8 {
|
if sigset_size != 8 {
|
||||||
return_errno_with_message!(Errno::EINVAL, "sigset size is not equal to 8")
|
return_errno_with_message!(Errno::EINVAL, "sigset size is not equal to 8")
|
||||||
}
|
}
|
||||||
do_rt_sigpending(u_set_ptr)?;
|
do_rt_sigpending(u_set_ptr, ctx)?;
|
||||||
Ok(SyscallReturn::Return(0))
|
Ok(SyscallReturn::Return(0))
|
||||||
}
|
}
|
||||||
|
|
||||||
fn do_rt_sigpending(set_ptr: Vaddr) -> Result<()> {
|
fn do_rt_sigpending(set_ptr: Vaddr, ctx: &Context) -> Result<()> {
|
||||||
let current_thread = current_thread!();
|
|
||||||
let posix_thread = current_thread.as_posix_thread().unwrap();
|
|
||||||
|
|
||||||
let combined_signals = {
|
let combined_signals = {
|
||||||
let sig_mask_value = posix_thread.sig_mask().load(Ordering::Relaxed);
|
let sig_mask_value = ctx.posix_thread.sig_mask().load(Ordering::Relaxed);
|
||||||
let sig_pending_value = posix_thread.sig_pending();
|
let sig_pending_value = ctx.posix_thread.sig_pending();
|
||||||
sig_mask_value & sig_pending_value
|
sig_mask_value & sig_pending_value
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -5,12 +5,9 @@ use core::sync::atomic::Ordering;
|
|||||||
use super::SyscallReturn;
|
use super::SyscallReturn;
|
||||||
use crate::{
|
use crate::{
|
||||||
prelude::*,
|
prelude::*,
|
||||||
process::{
|
process::signal::{
|
||||||
posix_thread::PosixThreadExt,
|
constants::{SIGKILL, SIGSTOP},
|
||||||
signal::{
|
sig_mask::SigMask,
|
||||||
constants::{SIGKILL, SIGSTOP},
|
|
||||||
sig_mask::SigMask,
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -19,7 +16,7 @@ pub fn sys_rt_sigprocmask(
|
|||||||
set_ptr: Vaddr,
|
set_ptr: Vaddr,
|
||||||
oldset_ptr: Vaddr,
|
oldset_ptr: Vaddr,
|
||||||
sigset_size: usize,
|
sigset_size: usize,
|
||||||
_ctx: &Context,
|
ctx: &Context,
|
||||||
) -> Result<SyscallReturn> {
|
) -> Result<SyscallReturn> {
|
||||||
let mask_op = MaskOp::try_from(how).unwrap();
|
let mask_op = MaskOp::try_from(how).unwrap();
|
||||||
debug!(
|
debug!(
|
||||||
@ -29,21 +26,23 @@ pub fn sys_rt_sigprocmask(
|
|||||||
if sigset_size != 8 {
|
if sigset_size != 8 {
|
||||||
error!("sigset size is not equal to 8");
|
error!("sigset size is not equal to 8");
|
||||||
}
|
}
|
||||||
do_rt_sigprocmask(mask_op, set_ptr, oldset_ptr).unwrap();
|
do_rt_sigprocmask(mask_op, set_ptr, oldset_ptr, ctx).unwrap();
|
||||||
Ok(SyscallReturn::Return(0))
|
Ok(SyscallReturn::Return(0))
|
||||||
}
|
}
|
||||||
|
|
||||||
fn do_rt_sigprocmask(mask_op: MaskOp, set_ptr: Vaddr, oldset_ptr: Vaddr) -> Result<()> {
|
fn do_rt_sigprocmask(
|
||||||
let current_thread = current_thread!();
|
mask_op: MaskOp,
|
||||||
let posix_thread = current_thread.as_posix_thread().unwrap();
|
set_ptr: Vaddr,
|
||||||
|
oldset_ptr: Vaddr,
|
||||||
let old_sig_mask_value = posix_thread.sig_mask().load(Ordering::Relaxed);
|
ctx: &Context,
|
||||||
|
) -> Result<()> {
|
||||||
|
let old_sig_mask_value = ctx.posix_thread.sig_mask().load(Ordering::Relaxed);
|
||||||
debug!("old sig mask value: 0x{:x}", old_sig_mask_value);
|
debug!("old sig mask value: 0x{:x}", old_sig_mask_value);
|
||||||
if oldset_ptr != 0 {
|
if oldset_ptr != 0 {
|
||||||
CurrentUserSpace::get().write_val(oldset_ptr, &old_sig_mask_value)?;
|
CurrentUserSpace::get().write_val(oldset_ptr, &old_sig_mask_value)?;
|
||||||
}
|
}
|
||||||
|
|
||||||
let sig_mask_ref = posix_thread.sig_mask();
|
let sig_mask_ref = ctx.posix_thread.sig_mask();
|
||||||
if set_ptr != 0 {
|
if set_ptr != 0 {
|
||||||
let mut read_mask = CurrentUserSpace::get().read_val::<SigMask>(set_ptr)?;
|
let mut read_mask = CurrentUserSpace::get().read_val::<SigMask>(set_ptr)?;
|
||||||
match mask_op {
|
match mask_op {
|
||||||
|
@ -1,15 +1,12 @@
|
|||||||
// SPDX-License-Identifier: MPL-2.0
|
// SPDX-License-Identifier: MPL-2.0
|
||||||
|
|
||||||
use super::SyscallReturn;
|
use super::SyscallReturn;
|
||||||
use crate::{
|
use crate::{prelude::*, process::posix_thread::RobustListHead};
|
||||||
prelude::*,
|
|
||||||
process::posix_thread::{PosixThreadExt, RobustListHead},
|
|
||||||
};
|
|
||||||
|
|
||||||
pub fn sys_set_robust_list(
|
pub fn sys_set_robust_list(
|
||||||
robust_list_head_ptr: Vaddr,
|
robust_list_head_ptr: Vaddr,
|
||||||
len: usize,
|
len: usize,
|
||||||
_ctx: &Context,
|
ctx: &Context,
|
||||||
) -> Result<SyscallReturn> {
|
) -> Result<SyscallReturn> {
|
||||||
debug!(
|
debug!(
|
||||||
"robust list head ptr: 0x{:x}, len = {}",
|
"robust list head ptr: 0x{:x}, len = {}",
|
||||||
@ -24,9 +21,7 @@ pub fn sys_set_robust_list(
|
|||||||
let robust_list_head: RobustListHead =
|
let robust_list_head: RobustListHead =
|
||||||
CurrentUserSpace::get().read_val(robust_list_head_ptr)?;
|
CurrentUserSpace::get().read_val(robust_list_head_ptr)?;
|
||||||
debug!("{:x?}", robust_list_head);
|
debug!("{:x?}", robust_list_head);
|
||||||
let current_thread = current_thread!();
|
let mut robust_list = ctx.posix_thread.robust_list().lock();
|
||||||
let posix_thread = current_thread.as_posix_thread().unwrap();
|
|
||||||
let mut robust_list = posix_thread.robust_list().lock();
|
|
||||||
*robust_list = Some(robust_list_head);
|
*robust_list = Some(robust_list_head);
|
||||||
Ok(SyscallReturn::Return(0))
|
Ok(SyscallReturn::Return(0))
|
||||||
}
|
}
|
||||||
|
@ -1,13 +1,11 @@
|
|||||||
// SPDX-License-Identifier: MPL-2.0
|
// SPDX-License-Identifier: MPL-2.0
|
||||||
|
|
||||||
use super::SyscallReturn;
|
use super::SyscallReturn;
|
||||||
use crate::{prelude::*, process::posix_thread::PosixThreadExt};
|
use crate::prelude::*;
|
||||||
|
|
||||||
pub fn sys_set_tid_address(tidptr: Vaddr, _ctx: &Context) -> Result<SyscallReturn> {
|
pub fn sys_set_tid_address(tidptr: Vaddr, ctx: &Context) -> Result<SyscallReturn> {
|
||||||
debug!("tidptr = 0x{:x}", tidptr);
|
debug!("tidptr = 0x{:x}", tidptr);
|
||||||
let current_thread = current_thread!();
|
let mut clear_child_tid = ctx.posix_thread.clear_child_tid().lock();
|
||||||
let posix_thread = current_thread.as_posix_thread().unwrap();
|
|
||||||
let mut clear_child_tid = posix_thread.clear_child_tid().lock();
|
|
||||||
if *clear_child_tid != 0 {
|
if *clear_child_tid != 0 {
|
||||||
// According to manuals at https://man7.org/linux/man-pages/man2/set_tid_address.2.html
|
// According to manuals at https://man7.org/linux/man-pages/man2/set_tid_address.2.html
|
||||||
// We need to write 0 to clear_child_tid and do futex wake
|
// We need to write 0 to clear_child_tid and do futex wake
|
||||||
@ -15,6 +13,6 @@ pub fn sys_set_tid_address(tidptr: Vaddr, _ctx: &Context) -> Result<SyscallRetur
|
|||||||
} else {
|
} else {
|
||||||
*clear_child_tid = tidptr;
|
*clear_child_tid = tidptr;
|
||||||
}
|
}
|
||||||
let tid = current_thread.tid();
|
let tid = ctx.thread.tid();
|
||||||
Ok(SyscallReturn::Return(tid as _))
|
Ok(SyscallReturn::Return(tid as _))
|
||||||
}
|
}
|
||||||
|
@ -3,16 +3,13 @@
|
|||||||
use super::SyscallReturn;
|
use super::SyscallReturn;
|
||||||
use crate::{
|
use crate::{
|
||||||
prelude::*,
|
prelude::*,
|
||||||
process::{
|
process::signal::{SigStack, SigStackFlags},
|
||||||
posix_thread::PosixThreadExt,
|
|
||||||
signal::{SigStack, SigStackFlags},
|
|
||||||
},
|
|
||||||
};
|
};
|
||||||
|
|
||||||
pub fn sys_sigaltstack(
|
pub fn sys_sigaltstack(
|
||||||
sig_stack_addr: Vaddr,
|
sig_stack_addr: Vaddr,
|
||||||
old_sig_stack_addr: Vaddr,
|
old_sig_stack_addr: Vaddr,
|
||||||
_ctx: &Context,
|
ctx: &Context,
|
||||||
) -> Result<SyscallReturn> {
|
) -> Result<SyscallReturn> {
|
||||||
debug!(
|
debug!(
|
||||||
"sig_stack_addr = 0x{:x}, old_sig_stack_addr: 0x{:x}",
|
"sig_stack_addr = 0x{:x}, old_sig_stack_addr: 0x{:x}",
|
||||||
@ -20,14 +17,12 @@ pub fn sys_sigaltstack(
|
|||||||
);
|
);
|
||||||
|
|
||||||
let old_stack = {
|
let old_stack = {
|
||||||
let current_thread = current_thread!();
|
let sig_stack = ctx.posix_thread.sig_stack().lock();
|
||||||
let posix_thread = current_thread.as_posix_thread().unwrap();
|
|
||||||
let sig_stack = posix_thread.sig_stack().lock();
|
|
||||||
sig_stack.clone()
|
sig_stack.clone()
|
||||||
};
|
};
|
||||||
|
|
||||||
get_old_stack(old_sig_stack_addr, old_stack.as_ref())?;
|
get_old_stack(old_sig_stack_addr, old_stack.as_ref())?;
|
||||||
set_new_stack(sig_stack_addr, old_stack.as_ref())?;
|
set_new_stack(sig_stack_addr, old_stack.as_ref(), ctx)?;
|
||||||
|
|
||||||
Ok(SyscallReturn::Return(0))
|
Ok(SyscallReturn::Return(0))
|
||||||
}
|
}
|
||||||
@ -47,7 +42,7 @@ fn get_old_stack(old_sig_stack_addr: Vaddr, old_stack: Option<&SigStack>) -> Res
|
|||||||
CurrentUserSpace::get().write_val(old_sig_stack_addr, &stack)
|
CurrentUserSpace::get().write_val(old_sig_stack_addr, &stack)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn set_new_stack(sig_stack_addr: Vaddr, old_stack: Option<&SigStack>) -> Result<()> {
|
fn set_new_stack(sig_stack_addr: Vaddr, old_stack: Option<&SigStack>, ctx: &Context) -> Result<()> {
|
||||||
if sig_stack_addr == 0 {
|
if sig_stack_addr == 0 {
|
||||||
return Ok(());
|
return Ok(());
|
||||||
}
|
}
|
||||||
@ -65,9 +60,7 @@ fn set_new_stack(sig_stack_addr: Vaddr, old_stack: Option<&SigStack>) -> Result<
|
|||||||
|
|
||||||
debug!("new_stack = {:?}", new_stack);
|
debug!("new_stack = {:?}", new_stack);
|
||||||
|
|
||||||
let current_thread = current_thread!();
|
*ctx.posix_thread.sig_stack().lock() = Some(new_stack);
|
||||||
let posix_thread = current_thread.as_posix_thread().unwrap();
|
|
||||||
*posix_thread.sig_stack().lock() = Some(new_stack);
|
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
@ -31,7 +31,7 @@ pub fn sys_timer_create(
|
|||||||
clockid: clockid_t,
|
clockid: clockid_t,
|
||||||
sigevent_addr: Vaddr,
|
sigevent_addr: Vaddr,
|
||||||
timer_id_addr: Vaddr,
|
timer_id_addr: Vaddr,
|
||||||
_ctx: &Context,
|
ctx: &Context,
|
||||||
) -> Result<SyscallReturn> {
|
) -> Result<SyscallReturn> {
|
||||||
if timer_id_addr == 0 {
|
if timer_id_addr == 0 {
|
||||||
return_errno_with_message!(
|
return_errno_with_message!(
|
||||||
@ -111,13 +111,7 @@ pub fn sys_timer_create(
|
|||||||
let clock_id = ClockId::try_from(clockid)?;
|
let clock_id = ClockId::try_from(clockid)?;
|
||||||
match clock_id {
|
match clock_id {
|
||||||
ClockId::CLOCK_PROCESS_CPUTIME_ID => process_timer_manager.create_prof_timer(func),
|
ClockId::CLOCK_PROCESS_CPUTIME_ID => process_timer_manager.create_prof_timer(func),
|
||||||
ClockId::CLOCK_THREAD_CPUTIME_ID => {
|
ClockId::CLOCK_THREAD_CPUTIME_ID => ctx.posix_thread.create_prof_timer(func),
|
||||||
let current_thread = current_thread!();
|
|
||||||
current_thread
|
|
||||||
.as_posix_thread()
|
|
||||||
.unwrap()
|
|
||||||
.create_prof_timer(func)
|
|
||||||
}
|
|
||||||
ClockId::CLOCK_REALTIME => RealTimeClock::timer_manager().create_timer(func),
|
ClockId::CLOCK_REALTIME => RealTimeClock::timer_manager().create_timer(func),
|
||||||
ClockId::CLOCK_MONOTONIC => MonotonicClock::timer_manager().create_timer(func),
|
ClockId::CLOCK_MONOTONIC => MonotonicClock::timer_manager().create_timer(func),
|
||||||
ClockId::CLOCK_BOOTTIME => BootTimeClock::timer_manager().create_timer(func),
|
ClockId::CLOCK_BOOTTIME => BootTimeClock::timer_manager().create_timer(func),
|
||||||
|
Reference in New Issue
Block a user