diff options
| author | rsc <rsc> | 2006-09-08 14:26:51 +0000 | 
|---|---|---|
| committer | rsc <rsc> | 2006-09-08 14:26:51 +0000 | 
| commit | 1656b1b2326069e82933cbaf34a68ca3abe2aa9d (patch) | |
| tree | 31578d8b8a2ee7f8881d9817ab1fe093af7fc9d3 | |
| parent | be29b8e263ee60c30e8f55162bc05ee4515634c9 (diff) | |
| download | xv6-labs-1656b1b2326069e82933cbaf34a68ca3abe2aa9d.tar.gz xv6-labs-1656b1b2326069e82933cbaf34a68ca3abe2aa9d.tar.bz2 xv6-labs-1656b1b2326069e82933cbaf34a68ca3abe2aa9d.zip  | |
move growproc up higher
| -rw-r--r-- | proc.c | 41 | 
1 files changed, 21 insertions, 20 deletions
@@ -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);    }  } +  | 
