LearningOS / rCore-Tutorial-Guide-2023S

GNU General Public License v3.0
12 stars 2 forks source link

rCore-Tutorial-Guide-2023S/chapter3/4time-sharing-system #8

Open utterances-bot opened 1 year ago

utterances-bot commented 1 year ago

分时多任务系统 - rCore-Tutorial-Guide-2023S 文档

https://learningos.github.io/rCore-Tutorial-Guide-2023S/chapter3/4time-sharing-system.html

jtzhpf commented 1 year ago

timer.rs中的这个注释是不是有点问题,这里以ticks为单位应该改成以clocks为单位吧?

/// Get the current time in ticks
pub fn get_time() -> usize {
    time::read()
}

看这下面三个函数,time::read()返回的应该是个clock数吧。

/// get current time in milliseconds
#[allow(dead_code)]
pub fn get_time_ms() -> usize {
    time::read() / (CLOCK_FREQ / MSEC_PER_SEC)
}

/// get current time in microseconds
#[allow(dead_code)]
pub fn get_time_us() -> usize {
    time::read() * MICRO_PER_SEC / CLOCK_FREQ
}

/// Set the next timer interrupt
pub fn set_next_trigger() {
    set_timer(get_time() + CLOCK_FREQ / TICKS_PER_SEC);
}
Unik-lif commented 1 year ago

嗯,我觉得是有问题的。不过在rCore-Tutorial中没有这个问题