kernel: print connection count on per-process output

Signed-off-by: Sean Cross <sean@xobs.io>
This commit is contained in:
Sean Cross 2022-04-05 15:11:47 +08:00
parent 5e369555d2
commit 6d294c97c5

View file

@ -9,6 +9,8 @@ use utralib::generated::*;
#[cfg(baremetal)] #[cfg(baremetal)]
pub static mut DEBUG_OUTPUT: Option<&'static mut dyn Write> = None; pub static mut DEBUG_OUTPUT: Option<&'static mut dyn Write> = None;
pub use crate::arch::process::Process as ArchProcess;
#[macro_use] #[macro_use]
#[cfg(all( #[cfg(all(
not(test), not(test),
@ -211,12 +213,21 @@ fn process_irq_character(b: u8) {
let current_pid = system_services.current_pid(); let current_pid = system_services.current_pid();
for process in &system_services.processes { for process in &system_services.processes {
if !process.free() { if !process.free() {
process.activate().unwrap();
let mut connection_count = 0;
ArchProcess::with_inner(|process_inner| {
for conn in &process_inner.connection_map {
if conn.is_some() {
connection_count += 1;
}
}
});
println!( println!(
"{:?} {}:", "{:?} conns:{}/32 {}",
process, process,
connection_count,
system_services.process_name(process.pid).unwrap_or("") system_services.process_name(process.pid).unwrap_or("")
); );
process.activate().unwrap();
} }
} }
system_services system_services