From 60064dbf1b3d2a5ba5ff12cec0e2804474bb1204 Mon Sep 17 00:00:00 2001 From: taiwoabe <143144801+taiwoabe@users.noreply.github.com> Date: Tue, 24 Sep 2024 18:48:13 -0500 Subject: [PATCH] Update sysproc.c --- kernel/sysproc.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/kernel/sysproc.c b/kernel/sysproc.c index 3b4d5bd863..d7ce6b0b41 100644 --- a/kernel/sysproc.c +++ b/kernel/sysproc.c @@ -5,6 +5,7 @@ #include "memlayout.h" #include "spinlock.h" #include "proc.h" +#include "mmu.h" uint64 sys_exit(void) @@ -91,3 +92,10 @@ sys_uptime(void) release(&tickslock); return xticks; } +extern int kfreepages(void); // Declaration of function that returns free pages + +int sys_getfreemem(void) { + // Calculate free memory in bytes, assuming PGSIZE is the size of each page + int free_pages = kfreepages(); // This function should return the number of free pages + return free_pages * PGSIZE; // Return the free memory in bytes +}