Fit exec on a page. Again
This commit is contained in:
parent
4e015d81aa
commit
5a97613bab
1 changed files with 2 additions and 5 deletions
7
exec.c
7
exec.c
|
@ -50,8 +50,7 @@ exec(char *path, char **argv)
|
||||||
ip = 0;
|
ip = 0;
|
||||||
|
|
||||||
// Allocate two pages at the next page boundary.
|
// Allocate two pages at the next page boundary.
|
||||||
// Make the first inaccessible.
|
// Make the first inaccessible. Use the second as the user stack.
|
||||||
// Use the second as the user stack.
|
|
||||||
sz = PGROUNDUP(sz);
|
sz = PGROUNDUP(sz);
|
||||||
if((sz = allocuvm(pgdir, sz, sz + 2*PGSIZE)) == 0)
|
if((sz = allocuvm(pgdir, sz, sz + 2*PGSIZE)) == 0)
|
||||||
goto bad;
|
goto bad;
|
||||||
|
@ -62,8 +61,7 @@ exec(char *path, char **argv)
|
||||||
for(argc = 0; argv[argc]; argc++) {
|
for(argc = 0; argv[argc]; argc++) {
|
||||||
if(argc >= MAXARG)
|
if(argc >= MAXARG)
|
||||||
goto bad;
|
goto bad;
|
||||||
sp -= strlen(argv[argc]) + 1;
|
sp = (sp - strlen(argv[argc]) + 1) & ~3;
|
||||||
sp &= ~3;
|
|
||||||
if(copyout(pgdir, sp, argv[argc], strlen(argv[argc]) + 1) < 0)
|
if(copyout(pgdir, sp, argv[argc], strlen(argv[argc]) + 1) < 0)
|
||||||
goto bad;
|
goto bad;
|
||||||
ustack[3+argc] = sp;
|
ustack[3+argc] = sp;
|
||||||
|
@ -92,7 +90,6 @@ exec(char *path, char **argv)
|
||||||
proc->tf->esp = sp;
|
proc->tf->esp = sp;
|
||||||
switchuvm(proc);
|
switchuvm(proc);
|
||||||
freevm(oldpgdir);
|
freevm(oldpgdir);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
bad:
|
bad:
|
||||||
|
|
Loading…
Reference in a new issue