summaryrefslogtreecommitdiff
path: root/proc.c
diff options
context:
space:
mode:
authorAustin Clements <[email protected]>2010-09-02 18:28:36 -0400
committerAustin Clements <[email protected]>2010-09-02 18:28:36 -0400
commit79cd8b3eedeb1f85d3b19fb6119bd5224c4c532a (patch)
treef9afe121e2b9298b35d3ccd61a329f03421c97fa /proc.c
parentd49d31381df93b40c1c4bc18c97ca42c3256e414 (diff)
downloadxv6-labs-79cd8b3eedeb1f85d3b19fb6119bd5224c4c532a.tar.gz
xv6-labs-79cd8b3eedeb1f85d3b19fb6119bd5224c4c532a.tar.bz2
xv6-labs-79cd8b3eedeb1f85d3b19fb6119bd5224c4c532a.zip
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).
Diffstat (limited to 'proc.c')
-rw-r--r--proc.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/proc.c b/proc.c
index 853eb0a..6f7bdb6 100644
--- a/proc.c
+++ b/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;
}