diff options
author | Mole Shang <[email protected]> | 2024-02-10 13:46:25 +0800 |
---|---|---|
committer | Mole Shang <[email protected]> | 2024-02-10 13:50:34 +0800 |
commit | 3673a2cdfb30e1e3936e695a3fb8adee74488d6b (patch) | |
tree | 282b4677f47bbb15949e24b3bfa455b173a38a29 /kernel/kalloc.c | |
parent | f379c1c4c80947365eb6c4046c3ab165629dc8cd (diff) | |
parent | c9284cd93525436cc823258ab309c1b27eeec714 (diff) | |
download | xv6-labs-3673a2cdfb30e1e3936e695a3fb8adee74488d6b.tar.gz xv6-labs-3673a2cdfb30e1e3936e695a3fb8adee74488d6b.tar.bz2 xv6-labs-3673a2cdfb30e1e3936e695a3fb8adee74488d6b.zip |
Merge branch 'pgtbl' into traps
Conflicts:
.gitignore
Makefile
conf/lab.mk
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; +} |