Skip to content

Commit

Permalink
更新内存占用统计方法
Browse files Browse the repository at this point in the history
  • Loading branch information
Minsecrus committed Nov 24, 2024
1 parent 6045b7e commit ef66599
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions src/sysapp/shell.c
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,19 @@ extern uint32_t phy_mem_size;
static void sys_info(){
cpu_t *cpu = get_cpuid();

uint32_t mb = get_kernel_memory_usage() / 1024;
extern void* program_break;
extern void* program_break_end;
uint32_t bytes = get_kernel_memory_usage() + (uint32_t)program_break + (uint32_t)program_break_end;

extern pcb_t *running_proc_head;
pcb_t *pcb = running_proc_head;
while(pcb != NULL){
pcb = pcb->next;
if(pcb->task_level != TASK_KERNEL_LEVEL){
bytes += (uint32_t)pcb->program_break + (uint32_t)pcb->program_break_end;
}
}
int memory = (bytes > 10485760) ? bytes/1048576 : bytes/1024;

printk(" -*&@@@&*- \n");
printk(" =&@@@@@@@@@:\033[36m-----\033[39m -----------------\n");
Expand All @@ -161,7 +173,7 @@ static void sys_info(){
printk("&@@@@@+ \033[36m&@@@@@=:\033[39m@@@& Time: %s\n",get_date_time());
printk("@@@@@@: \033[36m#&&&&=:\033[39m@@@@@ Console: os_terminal\n");
printk("&@@@@@+ +@@@@@& Kernel: %s\n",KERNEL_NAME);
printk("*@@@@@@ @@@@@@* Memory Usage: %dKB / %dMB\n",mb,(int)(phy_mem_size));
printk("*@@@@@@ @@@@@@* Memory Usage: %d%s / %dMB\n",memory,bytes > 10485760 ? "MB" : "KB",(int)(phy_mem_size));
printk("-@@@@@@* #@@@@@@: 32-bit operating system, x86-based processor\n");
printk(" &@@@@@@*. .#@@@@@@& \n");
printk(" =@@@@@@@@*---*@@@@@@@@- \n");
Expand Down

0 comments on commit ef66599

Please sign in to comment.