kernel: print running total of memory usage size

Print the total of all processes in the system.

Signed-off-by: Sean Cross <sean@xobs.io>
This commit is contained in:
Sean Cross 2021-05-10 15:09:46 +08:00
parent 7087fbe823
commit 1b7ee904b2

View file

@ -176,20 +176,24 @@ pub fn irq(_irq_number: usize, _arg: *mut usize) {
}
'r' => {
println!("RAM usage:");
let mut total_bytes = 0;
crate::services::SystemServices::with(|system_services| {
crate::mem::MemoryManager::with(|mm| {
for process in &system_services.processes {
if !process.free() {
let bytes_used = mm.ram_used_by(process.pid);
total_bytes += bytes_used;
println!(
" PID {}: {:>4} k {}",
" PID {:>3}: {:>4} k {}",
process.pid,
mm.ram_used_by(process.pid) / 1024,
bytes_used / 1024,
system_services.process_name(process.pid).unwrap_or("")
);
}
}
});
});
println!("{} k total", total_bytes / 1024);
}
_ => {}
}