summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorrsc <rsc>2006-09-08 14:26:51 +0000
committerrsc <rsc>2006-09-08 14:26:51 +0000
commit1656b1b2326069e82933cbaf34a68ca3abe2aa9d (patch)
tree31578d8b8a2ee7f8881d9817ab1fe093af7fc9d3
parentbe29b8e263ee60c30e8f55162bc05ee4515634c9 (diff)
downloadxv6-labs-1656b1b2326069e82933cbaf34a68ca3abe2aa9d.tar.gz
xv6-labs-1656b1b2326069e82933cbaf34a68ca3abe2aa9d.tar.bz2
xv6-labs-1656b1b2326069e82933cbaf34a68ca3abe2aa9d.zip
move growproc up higher
-rw-r--r--proc.c41
1 files changed, 21 insertions, 20 deletions
diff --git a/proc.c b/proc.c
index 76549ae..62c0b29 100644
--- a/proc.c
+++ b/proc.c
@@ -54,6 +54,26 @@ setupsegs(struct proc *p)
ltr(SEG_TSS << 3);
}
+// Grow current process's memory by n bytes.
+// Return old size on success, -1 on failure.
+int
+growproc(int n)
+{
+ struct proc *cp = curproc[cpu()];
+ char *newmem, *oldmem;
+
+ newmem = kalloc(cp->sz + n);
+ if(newmem == 0)
+ return 0xffffffff;
+ memmove(newmem, cp->mem, cp->sz);
+ memset(newmem + cp->sz, 0, n);
+ oldmem = cp->mem;
+ cp->mem = newmem;
+ kfree(oldmem, cp->sz);
+ cp->sz += n;
+ return cp->sz - n;
+}
+
// Look in the process table for an UNUSED proc.
// If found, change state to EMBRYO and return it.
// Otherwise return 0.
@@ -136,26 +156,6 @@ copyproc(struct proc *p)
return np;
}
-// Grow current process's memory by n bytes.
-// Return old size on success, -1 on failure.
-int
-growproc(int n)
-{
- struct proc *cp = curproc[cpu()];
- char *newmem, *oldmem;
-
- newmem = kalloc(cp->sz + n);
- if(newmem == 0)
- return 0xffffffff;
- memmove(newmem, cp->mem, cp->sz);
- memset(newmem + cp->sz, 0, n);
- oldmem = cp->mem;
- cp->mem = newmem;
- kfree(oldmem, cp->sz);
- cp->sz += n;
- return cp->sz - n;
-}
-
//PAGEBREAK: 42
// Per-CPU process scheduler.
// Each CPU calls scheduler() after setting itself up.
@@ -424,3 +424,4 @@ procdump(void)
cprintf("%d %d %p\n", p->pid, p->state);
}
}
+