diff options
author | Mole Shang <135e2@135e2.dev> | 2024-01-18 17:35:27 +0800 |
---|---|---|
committer | Mole Shang <135e2@135e2.dev> | 2024-01-18 17:35:27 +0800 |
commit | 493159b9bb1a764926daa49fb09bff8f29e8e9e5 (patch) | |
tree | bcae49e20df0ab9d86dab9bd10226807cc432f88 /kernel/kalloc.c | |
parent | 33ca12a4653752d179e6296c7ca2f91a626d30f3 (diff) | |
download | xv6-labs-493159b9bb1a764926daa49fb09bff8f29e8e9e5.tar.gz xv6-labs-493159b9bb1a764926daa49fb09bff8f29e8e9e5.tar.bz2 xv6-labs-493159b9bb1a764926daa49fb09bff8f29e8e9e5.zip |
lab syscall: finishsyscall
Diffstat (limited to 'kernel/kalloc.c')
-rw-r--r-- | kernel/kalloc.c | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/kernel/kalloc.c b/kernel/kalloc.c index 0699e7e..c2fdb86 100644 --- a/kernel/kalloc.c +++ b/kernel/kalloc.c @@ -80,3 +80,17 @@ kalloc(void) memset((char*)r, 5, PGSIZE); // fill with junk return (void*)r; } + +int +get_freemem(void) +{ + int n; + struct run *r; + + acquire(&kmem.lock); + for (n = 0, r = kmem.freelist; r; r = r->next) + n++; + release(&kmem.lock); + + return n * PGSIZE; +} |