diff options
author | rtm <rtm> | 2006-08-30 18:55:06 +0000 |
---|---|---|
committer | rtm <rtm> | 2006-08-30 18:55:06 +0000 |
commit | 2aa4c3bc29b67dcc4810aca96fd0ae8aa7c32b5e (patch) | |
tree | 63446e3d197769ba44a9e32a30a284327ec93af8 /kalloc.c | |
parent | 18432ed5edaeb2a6ffd91f557880c277d96784c1 (diff) | |
download | xv6-labs-2aa4c3bc29b67dcc4810aca96fd0ae8aa7c32b5e.tar.gz xv6-labs-2aa4c3bc29b67dcc4810aca96fd0ae8aa7c32b5e.tar.bz2 xv6-labs-2aa4c3bc29b67dcc4810aca96fd0ae8aa7c32b5e.zip |
complain if no disk 1
lots of cleanup
Diffstat (limited to 'kalloc.c')
-rw-r--r-- | kalloc.c | 45 |
1 files changed, 1 insertions, 44 deletions
@@ -23,8 +23,6 @@ struct run { }; struct run *freelist; -void ktest(void); - /* * initialize free list of physical pages. this code * cheats by just considering the one megabyte of pages @@ -43,7 +41,6 @@ kinit(void) mem = 256; // XXX cprintf("mem = %d\n", mem * PAGE); kfree(start, mem * PAGE); - ktest(); } void @@ -130,46 +127,6 @@ kalloc(int n) rr = &(*rr)->next; } release(&kalloc_lock); + cprintf("kalloc: out of memory\n"); return 0; } - -void -ktest(void) -{ - char *p1, *p2, *p3; - - // test coalescing - p1 = kalloc(4 * PAGE); - kfree(p1 + 3*PAGE, PAGE); - kfree(p1 + 2*PAGE, PAGE); - kfree(p1, PAGE); - kfree(p1 + PAGE, PAGE); - p2 = kalloc(4 * PAGE); - if(p2 != p1) - panic("ktest"); - kfree(p2, 4 * PAGE); - - // test finding first run that fits - p1 = kalloc(1 * PAGE); - p2 = kalloc(1 * PAGE); - kfree(p1, PAGE); - p3 = kalloc(2 * PAGE); - kfree(p2, PAGE); - kfree(p3, 2 * PAGE); - - // test running out of memory - p1 = 0; - while((p2 = kalloc(PAGE)) != 0){ - *(char**)p2 = p1; - p1 = p2; - } - while(p1){ - p2 = *(char **)p1; - kfree(p1, PAGE); - p1 = p2; - } - p1 = kalloc(PAGE * 20); - if(p1 == 0) - panic("ktest2"); - kfree(p1, PAGE * 20); -} |