mirror of
https://github.com/saymrwulf/xous-core.git
synced 2026-11-18 08:52:45 +00:00
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:
parent
7087fbe823
commit
1b7ee904b2
1 changed files with 6 additions and 2 deletions
|
|
@ -176,20 +176,24 @@ pub fn irq(_irq_number: usize, _arg: *mut usize) {
|
||||||
}
|
}
|
||||||
'r' => {
|
'r' => {
|
||||||
println!("RAM usage:");
|
println!("RAM usage:");
|
||||||
|
let mut total_bytes = 0;
|
||||||
crate::services::SystemServices::with(|system_services| {
|
crate::services::SystemServices::with(|system_services| {
|
||||||
crate::mem::MemoryManager::with(|mm| {
|
crate::mem::MemoryManager::with(|mm| {
|
||||||
for process in &system_services.processes {
|
for process in &system_services.processes {
|
||||||
if !process.free() {
|
if !process.free() {
|
||||||
|
let bytes_used = mm.ram_used_by(process.pid);
|
||||||
|
total_bytes += bytes_used;
|
||||||
println!(
|
println!(
|
||||||
" PID {}: {:>4} k {}",
|
" PID {:>3}: {:>4} k {}",
|
||||||
process.pid,
|
process.pid,
|
||||||
mm.ram_used_by(process.pid) / 1024,
|
bytes_used / 1024,
|
||||||
system_services.process_name(process.pid).unwrap_or("")
|
system_services.process_name(process.pid).unwrap_or("")
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
println!("{} k total", total_bytes / 1024);
|
||||||
}
|
}
|
||||||
_ => {}
|
_ => {}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue