Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update sysproc.c #265

Open
wants to merge 1 commit into
base: riscv
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions kernel/sysproc.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#include "memlayout.h"
#include "spinlock.h"
#include "proc.h"
#include "mmu.h"

uint64
sys_exit(void)
Expand Down Expand Up @@ -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
}