提交 ef934f44 创建 作者: Frans Kaashoek's avatar Frans Kaashoek

stupid.

上级 1ecab5f9
...@@ -32,12 +32,9 @@ kinit(void) ...@@ -32,12 +32,9 @@ kinit(void)
p = (char*)PGROUNDUP((uint)end); p = (char*)PGROUNDUP((uint)end);
n = (char*)PHYSTOP - p; n = (char*)PHYSTOP - p;
cprintf("n = %d\n", n);
n = n / PGSIZE; n = n / PGSIZE;
n = n / NCPU;
cprintf("n = %d\n", n); cprintf("n = %d end = 0x%x\n", n, p);
for (c = 0; c < NCPU; c++) { for (c = 0; c < NCPU; c++) {
for (i = 0; i < n; i++, p += PGSIZE) { for (i = 0; i < n; i++, p += PGSIZE) {
...@@ -59,6 +56,8 @@ kfree(char *v) ...@@ -59,6 +56,8 @@ kfree(char *v)
{ {
struct run *r; struct run *r;
// cprintf("%d: free 0x%x\n", cpu->id, v);
if((uint)v % PGSIZE || v < end || (uint)v >= PHYSTOP) if((uint)v % PGSIZE || v < end || (uint)v >= PHYSTOP)
panic("kfree"); panic("kfree");
...@@ -80,7 +79,8 @@ kalloc(void) ...@@ -80,7 +79,8 @@ kalloc(void)
{ {
struct run *r; struct run *r;
cprintf("%d: kalloc\n", cpunum()); // cprintf("%d: kalloc 0x%x 0x%x 0x%x 0x%x 0%x\n", cpu->id, kmem, &kmems[cpu->id], kmem->freelist, PHYSTOP, kmems[1].freelist);
acquire(&kmem->lock); acquire(&kmem->lock);
r = kmem->freelist; r = kmem->freelist;
if(r) if(r)
......
...@@ -50,6 +50,7 @@ found: ...@@ -50,6 +50,7 @@ found:
release(&ptable->lock); release(&ptable->lock);
// Allocate kernel stack if possible. // Allocate kernel stack if possible.
cprintf("allocproc: kalloc\n");
if((p->kstack = kalloc()) == 0){ if((p->kstack = kalloc()) == 0){
p->state = UNUSED; p->state = UNUSED;
return 0; return 0;
......
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论