Skip to content
Snippets Groups Projects
Commit 1656b1b2 authored by rsc's avatar rsc
Browse files

move growproc up higher

parent be29b8e2
No related branches found
No related tags found
No related merge requests found
......@@ -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);
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment