Show argv[0] when printing process memory usage
This commit is contained in:
parent
3b2cf8bbb5
commit
07393d8c71
@ -2,7 +2,9 @@ use crate::{
|
|||||||
gdt, println, qemu_exit,
|
gdt, println, qemu_exit,
|
||||||
virtual_memory::{ASpaceMutex, AddressSpace, PagingError, ACTIVE_SPACE, KERNEL_SPACE},
|
virtual_memory::{ASpaceMutex, AddressSpace, PagingError, ACTIVE_SPACE, KERNEL_SPACE},
|
||||||
};
|
};
|
||||||
use alloc::{borrow::ToOwned, boxed::Box, collections::VecDeque, ffi::CString, vec::Vec};
|
use alloc::{
|
||||||
|
borrow::ToOwned, boxed::Box, collections::VecDeque, ffi::CString, string::ToString, vec::Vec,
|
||||||
|
};
|
||||||
use core::{
|
use core::{
|
||||||
alloc::Layout,
|
alloc::Layout,
|
||||||
arch::asm,
|
arch::asm,
|
||||||
@ -14,7 +16,6 @@ use humansize::{SizeFormatter, BINARY};
|
|||||||
use slab::Slab;
|
use slab::Slab;
|
||||||
use spin::{Lazy, Mutex, RwLock};
|
use spin::{Lazy, Mutex, RwLock};
|
||||||
use x86_64::{
|
use x86_64::{
|
||||||
instructions::interrupts,
|
|
||||||
structures::paging::{Page, PageTableFlags},
|
structures::paging::{Page, PageTableFlags},
|
||||||
VirtAddr,
|
VirtAddr,
|
||||||
};
|
};
|
||||||
@ -168,8 +169,9 @@ impl Tasking {
|
|||||||
)]
|
)]
|
||||||
args_layout.align_to(4096).unwrap().pad_to_align()
|
args_layout.align_to(4096).unwrap().pad_to_align()
|
||||||
};
|
};
|
||||||
let user_arg_mem =
|
let user_arg_mem = KERNEL_SPACE
|
||||||
address_space.map_free(args_layout.size() / 4096, PageTableFlags::USER_ACCESSIBLE)?;
|
.lock()
|
||||||
|
.map_free(args_layout.size() / 4096, PageTableFlags::USER_ACCESSIBLE)?;
|
||||||
address_space.run(|| unsafe {
|
address_space.run(|| unsafe {
|
||||||
let mut ptr_ptr: *mut *const u8 = user_arg_mem.cast();
|
let mut ptr_ptr: *mut *const u8 = user_arg_mem.cast();
|
||||||
for (&offset, argument) in arg_offsets.iter().zip(arguments.iter()) {
|
for (&offset, argument) in arg_offsets.iter().zip(arguments.iter()) {
|
||||||
@ -391,7 +393,19 @@ impl Tasking {
|
|||||||
|space| space.get_bytes_allocated(),
|
|space| space.get_bytes_allocated(),
|
||||||
);
|
);
|
||||||
total += bytes_used;
|
total += bytes_used;
|
||||||
println!("[TASKING] PID {} used {}", i, SizeFormatter::new(bytes_used, BINARY),);
|
let name = if process.arguments.1 > 0 {
|
||||||
|
unsafe { CStr::from_ptr(process.arguments.0.read().cast()) }
|
||||||
|
.to_string_lossy()
|
||||||
|
.into_owned()
|
||||||
|
} else {
|
||||||
|
"UNKNOWN".to_string()
|
||||||
|
};
|
||||||
|
println!(
|
||||||
|
"[TASKING] PID {} ({}) used {}",
|
||||||
|
i,
|
||||||
|
name,
|
||||||
|
SizeFormatter::new(bytes_used, BINARY),
|
||||||
|
);
|
||||||
}
|
}
|
||||||
println!("[TASKING] Total used {} ({})", SizeFormatter::new(total, BINARY), total / 4096);
|
println!("[TASKING] Total used {} ({})", SizeFormatter::new(total, BINARY), total / 4096);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user