allow sbrk(-x) to de-allocate user memory
This commit is contained in:
parent
c4cc10da7e
commit
83d2db91f7
4 changed files with 89 additions and 4 deletions
9
proc.c
9
proc.c
|
@ -142,8 +142,13 @@ userinit(void)
|
|||
int
|
||||
growproc(int n)
|
||||
{
|
||||
if (!allocuvm(proc->pgdir, (char *)proc->sz, n))
|
||||
return -1;
|
||||
if(n > 0){
|
||||
if (!allocuvm(proc->pgdir, (char *)proc->sz, n))
|
||||
return -1;
|
||||
} else if(n < 0){
|
||||
if (!deallocuvm(proc->pgdir, (char *)(proc->sz + n), 0 - n))
|
||||
return -1;
|
||||
}
|
||||
proc->sz += n;
|
||||
switchuvm(proc);
|
||||
return 0;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue