Struct axtask::CurrentTask

source ·
pub struct CurrentTask(/* private fields */);
Available on crate feature multitask only.
Expand description

A wrapper of AxTaskRef as the current task.

Implementations§

Methods from Deref<Target = TaskInner>§

source

pub fn id(&self) -> TaskId

Gets the ID of the task.

source

pub fn name(&self) -> &str

Gets the name of the task.

source

pub fn set_name(&self, name: &str)

Sets the name of the task.

source

pub fn id_name(&self) -> String

Get a combined string of the task ID and name.

source

pub fn join(&self) -> Option<i32>

Wait for the task to exit, and return the exit code.

It will return immediately if the task has already exited (but not dropped).

source

pub fn get_kernel_stack_top(&self) -> Option<usize>

获取内核栈栈顶

source

pub fn set_child_tid(&self, tid: usize)

Available on crate feature monolithic only.

store the child thread ID at the location pointed to by child_tid in clone args

source

pub fn set_clear_child_tid(&self, tid: usize)

Available on crate feature monolithic only.

clear (zero) the child thread ID at the location pointed to by child_tid in clone args

source

pub fn get_clear_child_tid(&self) -> usize

Available on crate feature monolithic only.

get the pointer to the child thread ID

source

pub fn get_page_table_token(&self) -> usize

Available on crate feature monolithic only.

get the page table token of the process which the task belongs to

source

pub fn set_page_table_token(&self, token: usize)

Available on crate feature monolithic only.

force to set the page table token of the process UNSAFELY

source

pub fn time_stat_from_user_to_kernel(&self)

Available on crate feature monolithic only.

update the time information when the task is switched from user mode to kernel mode

source

pub fn time_stat_from_kernel_to_user(&self)

Available on crate feature monolithic only.

update the time information when the task is switched from kernel mode to user mode

source

pub fn time_stat_when_switch_from(&self)

Available on crate feature monolithic only.

update the time information when the task is switched out

source

pub fn time_stat_when_switch_to(&self)

Available on crate feature monolithic only.

update the time information when the task is ready to be switched in

source

pub fn time_stat_output(&self) -> (usize, usize, usize, usize)

Available on crate feature monolithic only.

将内核统计的运行时时间转为秒与微妙的形式输出,方便进行sys_time (用户态秒,用户态微妙,内核态秒,内核态微妙)

source

pub fn timer_output(&self) -> (usize, usize)

Available on crate feature monolithic only.

输出计时器信息 (计时器周期,当前计时器剩余时间) 单位为us

source

pub fn set_timer( &self, timer_interval_ns: usize, timer_remained_ns: usize, timer_type: usize ) -> bool

Available on crate feature monolithic only.

设置计时器信息

若type不为None则返回成功

source

pub fn time_stat_clear(&self)

Available on crate feature monolithic only.

重置统计时间

source

pub fn get_process_id(&self) -> u64

Available on crate feature monolithic only.

get the process ID of the task

source

pub fn set_process_id(&self, process_id: u64)

Available on crate feature monolithic only.

set the process ID of the task

source

pub fn get_first_trap_frame(&self) -> *mut TrapFrame

Available on crate feature monolithic only.

获取内核栈的第一个trap上下文

source

pub fn set_leader(&self, is_lead: bool)

Available on crate feature monolithic only.

set the flag whether the task is the main thread of the process

source

pub fn is_leader(&self) -> bool

Available on crate feature monolithic only.

whether the task is the main thread of the process

source

pub fn set_trap_context(&self, trap_frame: TrapFrame)

Available on crate feature monolithic only.

设置Trap上下文

source

pub fn set_trap_in_kernel_stack(&self)

Available on crate feature monolithic only.

将trap上下文直接写入到内核栈上 注意此时保持sp不变 返回值为压入了trap之后的内核栈的栈顶,可以用于多层trap压入

source

pub fn set_cpu_set(&self, mask: usize, set_size: usize)

Available on crate feature monolithic only.

设置CPU set,其中set_size为bytes长度

source

pub fn get_cpu_set(&self) -> usize

Available on crate feature monolithic only.

to get the CPU set

source

pub fn set_sched_status(&self, status: SchedStatus)

Available on crate feature monolithic only.

set the scheduling policy and priority

source

pub fn get_sched_status(&self) -> SchedStatus

Available on crate feature monolithic only.

get the scheduling policy and priority

source

pub fn get_ctx(&self) -> &TaskContext

Available on crate feature monolithic only.

get the task context for task switch

source

pub fn get_sig_child(&self) -> bool

Available on crate features monolithic and signal only.

whether to send SIG_CHILD when the task exits

source

pub unsafe fn set_tls_force(&self, value: usize)

Available on crate feature monolithic and x86-64 only.
Safety

It is unsafe because it may cause undefined behavior if the fs_base is not a valid address.

source

pub fn is_vfork(&self) -> bool

Available on crate feature monolithic only.

获取父进程blocked_by_vfork布尔值

source

pub fn state(&self) -> TaskState

the state of the task

source

pub fn set_state(&self, state: TaskState)

set the state of the task

Trait Implementations§

source§

impl Deref for CurrentTask

§

type Target = TaskInner

The resulting type after dereferencing.
source§

fn deref(&self) -> &Self::Target

Dereferences the value.

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for Twhere U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.