summaryrefslogtreecommitdiff
path: root/kalloc.c
diff options
context:
space:
mode:
authorRobert Morris <[email protected]>2010-09-19 07:18:42 -0400
committerRobert Morris <[email protected]>2010-09-19 07:18:42 -0400
commit4587b35847b116057e3ef1058da914b8837ff343 (patch)
tree3c1fbcd2f348c804d21828adce07d67fc3801490 /kalloc.c
parentfaad047ab22cbe989c208bff5ecb42608ecb8d7b (diff)
downloadxv6-labs-4587b35847b116057e3ef1058da914b8837ff343.tar.gz
xv6-labs-4587b35847b116057e3ef1058da914b8837ff343.tar.bz2
xv6-labs-4587b35847b116057e3ef1058da914b8837ff343.zip
exec questions
Diffstat (limited to 'kalloc.c')
-rw-r--r--kalloc.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/kalloc.c b/kalloc.c
index 5f690f5..72ce58a 100644
--- a/kalloc.c
+++ b/kalloc.c
@@ -17,12 +17,12 @@ struct {
struct run *freelist;
} kmem;
+extern char end[]; // first address after kernel loaded from ELF file
+
// Initialize free list of physical pages.
void
kinit(void)
{
- extern char end[];
-
initlock(&kmem.lock, "kmem");
char *p = (char*)PGROUNDUP((uint)end);
for( ; p + PGSIZE - 1 < (char*) PHYSTOP; p += PGSIZE)
@@ -39,7 +39,7 @@ kfree(char *v)
{
struct run *r;
- if(((uint) v) % PGSIZE || (uint)v < 1024*1024 || (uint)v >= PHYSTOP)
+ if(((uint) v) % PGSIZE || v < end || (uint)v >= PHYSTOP)
panic("kfree");
// Fill with junk to catch dangling refs.