Simplify allocuvm/deallocuvm to operate in a contiguous memory model. This makes their interface match up better with proc->sz and also simplifies the callers (it even gets the main body of exec on one page).
This commit is contained in:
parent
d49d31381d
commit
79cd8b3eed
4 changed files with 44 additions and 51 deletions
7
proc.c
7
proc.c
|
@ -142,14 +142,15 @@ userinit(void)
|
|||
int
|
||||
growproc(int n)
|
||||
{
|
||||
uint sz = proc->sz;
|
||||
if(n > 0){
|
||||
if(!allocuvm(proc->pgdir, (char *)proc->sz, n))
|
||||
if(!(sz = allocuvm(proc->pgdir, sz, sz + n)))
|
||||
return -1;
|
||||
} else if(n < 0){
|
||||
if(!deallocuvm(proc->pgdir, (char *)(proc->sz + n), 0 - n))
|
||||
if(!(sz = deallocuvm(proc->pgdir, sz, sz + n)))
|
||||
return -1;
|
||||
}
|
||||
proc->sz += n;
|
||||
proc->sz = sz;
|
||||
switchuvm(proc);
|
||||
return 0;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue