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;
 | 
			
		||||
 | 
			
		||||
  // Allocate two pages at the next page boundary.
 | 
			
		||||
  // Make the first inaccessible.
 | 
			
		||||
  // Use the second as the user stack.
 | 
			
		||||
  // Make the first inaccessible.  Use the second as the user stack.
 | 
			
		||||
  sz = PGROUNDUP(sz);
 | 
			
		||||
  if((sz = allocuvm(pgdir, sz, sz + 2*PGSIZE)) == 0)
 | 
			
		||||
    goto bad;
 | 
			
		||||
| 
						 | 
				
			
			@ -62,8 +61,7 @@ exec(char *path, char **argv)
 | 
			
		|||
  for(argc = 0; argv[argc]; argc++) {
 | 
			
		||||
    if(argc >= MAXARG)
 | 
			
		||||
      goto bad;
 | 
			
		||||
    sp -= strlen(argv[argc]) + 1;
 | 
			
		||||
    sp &= ~3;
 | 
			
		||||
    sp = (sp - strlen(argv[argc]) + 1) & ~3;
 | 
			
		||||
    if(copyout(pgdir, sp, argv[argc], strlen(argv[argc]) + 1) < 0)
 | 
			
		||||
      goto bad;
 | 
			
		||||
    ustack[3+argc] = sp;
 | 
			
		||||
| 
						 | 
				
			
			@ -92,7 +90,6 @@ exec(char *path, char **argv)
 | 
			
		|||
  proc->tf->esp = sp;
 | 
			
		||||
  switchuvm(proc);
 | 
			
		||||
  freevm(oldpgdir);
 | 
			
		||||
 | 
			
		||||
  return 0;
 | 
			
		||||
 | 
			
		||||
 bad:
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		
		Reference in a new issue