syscall lab finished

This commit is contained in:
2025-03-25 11:36:21 +08:00
parent a087b429df
commit 992f76ca30
11 changed files with 223 additions and 2 deletions

View File

@ -7,6 +7,7 @@
#include "memlayout.h"
#include "spinlock.h"
#include "riscv.h"
#include "proc.h"
#include "defs.h"
void freerange(void *pa_start, void *pa_end);
@ -80,3 +81,17 @@ kalloc(void)
memset((char*)r, 5, PGSIZE); // fill with junk
return (void*)r;
}
int
freemem(void)
{
struct run* p = kmem.freelist;
uint64 num = 0;
while (p) {
num += 1;
p = p->next;
}
return num * PGSIZE;
}