move growproc up higher

This commit is contained in:
rsc 2006-09-08 14:26:51 +00:00
parent be29b8e263
commit 1656b1b232

41
proc.c
View file

@ -54,6 +54,26 @@ setupsegs(struct proc *p)
ltr(SEG_TSS << 3); 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. // Look in the process table for an UNUSED proc.
// If found, change state to EMBRYO and return it. // If found, change state to EMBRYO and return it.
// Otherwise return 0. // Otherwise return 0.
@ -136,26 +156,6 @@ copyproc(struct proc *p)
return np; 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 //PAGEBREAK: 42
// Per-CPU process scheduler. // Per-CPU process scheduler.
// Each CPU calls scheduler() after setting itself up. // Each CPU calls scheduler() after setting itself up.
@ -424,3 +424,4 @@ procdump(void)
cprintf("%d %d %p\n", p->pid, p->state); cprintf("%d %d %p\n", p->pid, p->state);
} }
} }