Struct taskctx::TimeStat

source ·
pub struct TimeStat { /* private fields */ }
Expand description

任务时间统计结构

Implementations§

source§

impl TimeStat

source

pub fn new() -> Self

新建一个进程时需要初始化时间

source

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

To get the time statistics

The format is (user time, kernel time) in nanoseconds

source

pub fn reset(&mut self, current_timestamp: usize)

复位时间统计器

source

pub fn switch_into_kernel_mode(&mut self, tid: isize, current_timestamp: usize)

从用户态进入内核态,记录当前时间戳,统计用户态时间

source

pub fn switch_into_user_mode(&mut self, tid: isize, current_timestamp: usize)

从内核态进入用户态,记录当前时间戳,统计内核态时间

source

pub fn swtich_from_old_task(&mut self, tid: isize, current_timestamp: usize)

内核态下,当前任务被切换掉,统计内核态时间

source

pub fn switch_to_new_task(&mut self, tid: isize, current_timestamp: usize)

内核态下,切换到当前任务,更新内核态时间戳

source

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

以微秒形式输出计时器信息

(计时器周期,当前计时器剩余时间)

source

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

设定计时器信息

若type不为None则返回成功

source

pub fn update_timer(&mut self, delta: usize, _tid: isize)

更新计时器,同时判断是否要发出信号

source

pub fn check_pending_timer_signal(&mut self) -> Option<usize>

Return

If the timer has triggered, return the signal number and reset the timer Otherwise, return None

Reference:

  1. https://man7.org/linux/man-pages/man2/setitimer.2.html
  2. https://github.com/bminor/musl/blob/master/arch/x86_64/bits/signal.h

Trait Implementations§

source§

impl Default for TimeStat

source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

source§

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

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where 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 T
where 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 T
where 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 T
where 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.