Skip to content

Commit

Permalink
feat(kernel): add dump rt command
Browse files Browse the repository at this point in the history
  • Loading branch information
hawkw committed Dec 1, 2022
1 parent 2677d19 commit 1cc8523
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
20 changes: 19 additions & 1 deletion src/rt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use maitake::{
scheduler::{self, StaticScheduler, Stealer},
time,
};
use mycelium_util::sync::InitOnce;
use mycelium_util::{fmt, sync::InitOnce};
use rand::Rng;

pub use maitake::task::JoinHandle;
Expand Down Expand Up @@ -95,6 +95,13 @@ pub fn init() {
tracing::info!("kernel runtime initialized");
}

pub const DUMP_RT: crate::shell::Command = crate::shell::Command::new("rt")
.with_help("print the kernel's async runtime")
.with_fn(|_| {
tracing::info!(runtime = ?RUNTIME);
Ok(())
});

static SCHEDULER: arch::LocalKey<Cell<Option<&'static StaticScheduler>>> =
arch::LocalKey::new(|| Cell::new(None));

Expand Down Expand Up @@ -281,3 +288,14 @@ impl Runtime {
self.cores[idx].try_get()?.try_steal().ok()
}
}

impl fmt::Debug for Runtime {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
let cores = self.active_cores();
f.debug_struct("Runtime")
.field("active_cores", &cores)
.field("cores", &&self.cores[..cores])
.field("injector", &self.injector)
.finish()
}
}
1 change: 1 addition & 0 deletions src/shell.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ pub fn eval(line: &str) {
tracing::info!(timer = ?crate::rt::TIMER);
Ok(())
}),
crate::rt::DUMP_RT,
crate::arch::shell::DUMP_ARCH,
Command::new("heap")
.with_help("print kernel heap statistics")
Expand Down

0 comments on commit 1cc8523

Please sign in to comment.