Enable IRQs before leaving the OSTD boot routine

This commit is contained in:
Zhang Junyang
2024-08-12 13:01:01 +00:00
committed by Tate, Hongliang Tian
parent 20d5212910
commit 491e4325fa
7 changed files with 42 additions and 55 deletions

View File

@ -89,9 +89,6 @@ fn init_thread() {
// Work queue should be initialized before interrupt is enabled,
// in case any irq handler uses work queue as bottom half
thread::work_queue::init();
// FIXME: Remove this if we move the step of mounting
// the filesystems to be done within the init process.
ostd::trap::enable_local();
net::lazy_init();
fs::lazy_init();
// driver::pci::virtio::block::block_device_test();

View File

@ -18,12 +18,14 @@ use ostd::{
use super::Process;
use crate::{
prelude::*,
process::{
posix_thread::PosixThreadExt,
signal::{constants::SIGALRM, signals::kernel::KernelSignal},
},
thread::work_queue::{submit_work_item, work_item::WorkItem},
thread::{
work_queue::{submit_work_item, work_item::WorkItem},
Thread,
},
time::{
clocks::{ProfClock, RealTimeClock},
Timer, TimerManager,
@ -36,40 +38,43 @@ use crate::{
/// invoke the callbacks of expired timers which are based on the updated
/// CPU clock.
fn update_cpu_time() {
let current_thread = current_thread!();
if let Some(posix_thread) = current_thread.as_posix_thread() {
let process = posix_thread.process();
let timer_manager = process.timer_manager();
let jiffies_interval = Duration::from_millis(1000 / TIMER_FREQ);
// Based on whether the timer interrupt occurs in kernel mode or user mode,
// the function will add the duration of one timer interrupt interval to the
// corresponding CPU clocks.
if is_kernel_interrupted() {
posix_thread
.prof_clock()
.kernel_clock()
.add_time(jiffies_interval);
process
.prof_clock()
.kernel_clock()
.add_time(jiffies_interval);
} else {
posix_thread
.prof_clock()
.user_clock()
.add_time(jiffies_interval);
process.prof_clock().user_clock().add_time(jiffies_interval);
timer_manager
.virtual_timer()
.timer_manager()
.process_expired_timers();
}
let Some(current_thread) = Thread::current() else {
return;
};
let Some(posix_thread) = current_thread.as_posix_thread() else {
return;
};
let process = posix_thread.process();
let timer_manager = process.timer_manager();
let jiffies_interval = Duration::from_millis(1000 / TIMER_FREQ);
// Based on whether the timer interrupt occurs in kernel mode or user mode,
// the function will add the duration of one timer interrupt interval to the
// corresponding CPU clocks.
if is_kernel_interrupted() {
posix_thread
.prof_clock()
.kernel_clock()
.add_time(jiffies_interval);
process
.prof_clock()
.kernel_clock()
.add_time(jiffies_interval);
} else {
posix_thread
.prof_clock()
.user_clock()
.add_time(jiffies_interval);
process.prof_clock().user_clock().add_time(jiffies_interval);
timer_manager
.prof_timer()
.virtual_timer()
.timer_manager()
.process_expired_timers();
posix_thread.process_expired_timers();
}
timer_manager
.prof_timer()
.timer_manager()
.process_expired_timers();
posix_thread.process_expired_timers();
}
/// Registers a function to update the CPU clock in processes and

View File

@ -190,7 +190,7 @@ fn taskless_softirq_handler(
mod test {
use core::sync::atomic::AtomicUsize;
use ostd::{prelude::*, trap::enable_local};
use ostd::prelude::*;
use super::*;
@ -198,7 +198,6 @@ mod test {
static DONE: AtomicBool = AtomicBool::new(false);
if !DONE.load(Ordering::SeqCst) {
super::init();
enable_local();
DONE.store(true, Ordering::SeqCst);
}
}