more sbrk fixes
This commit is contained in:
		
							parent
							
								
									0e131b2263
								
							
						
					
					
						commit
						cff3ce6e04
					
				
					 5 changed files with 22 additions and 23 deletions
				
			
		
							
								
								
									
										4
									
								
								proc.c
									
										
									
									
									
								
							
							
						
						
									
										4
									
								
								proc.c
									
										
									
									
									
								
							|  | @ -500,8 +500,6 @@ wakeup(void *chan) | |||
|   release(&ptable.lock); | ||||
| } | ||||
| 
 | ||||
| #if 0 | ||||
| 
 | ||||
| // Kill the process with the given pid.
 | ||||
| // Process won't exit until it returns
 | ||||
| // to user space (see trap in trap.c).
 | ||||
|  | @ -525,8 +523,6 @@ kill(int pid) | |||
|   return -1; | ||||
| } | ||||
| 
 | ||||
| #endif | ||||
| 
 | ||||
| // Copy to either a user address, or kernel address,
 | ||||
| // depending on usr_dst.
 | ||||
| // Returns 0 on success, -1 on error.
 | ||||
|  |  | |||
|  | @ -144,15 +144,15 @@ static int (*syscalls[])(void) = { | |||
| [SYS_wait]    sys_wait, | ||||
| [SYS_pipe]    sys_pipe, | ||||
| [SYS_read]    sys_read, | ||||
| //[SYS_kill]    sys_kill,
 | ||||
| [SYS_kill]    sys_kill, | ||||
| [SYS_exec]    sys_exec, | ||||
| [SYS_fstat]   sys_fstat, | ||||
| [SYS_chdir]   sys_chdir, | ||||
| [SYS_dup]     sys_dup, | ||||
| [SYS_getpid]  sys_getpid, | ||||
| [SYS_sbrk]    sys_sbrk, | ||||
| //[SYS_sleep]   sys_sleep,
 | ||||
| //[SYS_uptime]  sys_uptime,
 | ||||
| [SYS_sleep]   sys_sleep, | ||||
| [SYS_uptime]  sys_uptime, | ||||
| [SYS_open]    sys_open, | ||||
| [SYS_write]   sys_write, | ||||
| [SYS_mknod]   sys_mknod, | ||||
|  |  | |||
							
								
								
									
										23
									
								
								sysproc.c
									
										
									
									
									
								
							
							
						
						
									
										23
									
								
								sysproc.c
									
										
									
									
									
								
							|  | @ -39,24 +39,12 @@ sys_sbrk(void) | |||
| 
 | ||||
|   if(argint(0, &n) < 0) | ||||
|     return -1; | ||||
|   printf("sbrk(%d), sz was %d\n", n, (int)myproc()->sz); | ||||
|   addr = myproc()->sz; | ||||
|   if(growproc(n) < 0) | ||||
|     return -1; | ||||
|   return addr; | ||||
| } | ||||
| 
 | ||||
| #if 0 | ||||
| int | ||||
| sys_kill(void) | ||||
| { | ||||
|   int pid; | ||||
| 
 | ||||
|   if(argint(0, &pid) < 0) | ||||
|     return -1; | ||||
|   return kill(pid); | ||||
| } | ||||
| 
 | ||||
| int | ||||
| sys_sleep(void) | ||||
| { | ||||
|  | @ -78,6 +66,16 @@ sys_sleep(void) | |||
|   return 0; | ||||
| } | ||||
| 
 | ||||
| int | ||||
| sys_kill(void) | ||||
| { | ||||
|   int pid; | ||||
| 
 | ||||
|   if(argint(0, &pid) < 0) | ||||
|     return -1; | ||||
|   return kill(pid); | ||||
| } | ||||
| 
 | ||||
| // return how many clock tick interrupts have occurred
 | ||||
| // since start.
 | ||||
| int | ||||
|  | @ -90,4 +88,3 @@ sys_uptime(void) | |||
|   release(&tickslock); | ||||
|   return xticks; | ||||
| } | ||||
| #endif | ||||
|  |  | |||
							
								
								
									
										5
									
								
								trap.c
									
										
									
									
									
								
							
							
						
						
									
										5
									
								
								trap.c
									
										
									
									
									
								
							|  | @ -57,9 +57,12 @@ usertrap(void) | |||
|   } else { | ||||
|     printf("usertrap(): unexpected scause 0x%x pid=%d\n", r_scause(), p->pid); | ||||
|     printf("            sepc=%p stval=%p\n", r_sepc(), r_stval()); | ||||
|     panic("usertrap"); | ||||
|     p->killed = 1; | ||||
|   } | ||||
| 
 | ||||
|   if(p->killed) | ||||
|     exit(); | ||||
| 
 | ||||
|   usertrapret(); | ||||
| } | ||||
| 
 | ||||
|  |  | |||
							
								
								
									
										7
									
								
								vm.c
									
										
									
									
									
								
							
							
						
						
									
										7
									
								
								vm.c
									
										
									
									
									
								
							|  | @ -148,8 +148,10 @@ unmappages(pagetable_t pagetable, uint64 va, uint64 size, int do_free) | |||
|   for(;;){ | ||||
|     if((pte = walk(pagetable, a, 0)) == 0) | ||||
|       panic("unmappages: walk"); | ||||
|     if((*pte & PTE_V) == 0) | ||||
|     if((*pte & PTE_V) == 0){ | ||||
|       printf("va=%p pte=%p\n", a, *pte); | ||||
|       panic("unmappages: not mapped"); | ||||
|     } | ||||
|     if(PTE_FLAGS(*pte) == PTE_V) | ||||
|       panic("unmappages: not a leaf"); | ||||
|     if(do_free){ | ||||
|  | @ -203,7 +205,8 @@ uvmalloc(pagetable_t pagetable, uint64 oldsz, uint64 newsz) | |||
|   if(newsz < oldsz) | ||||
|     return oldsz; | ||||
| 
 | ||||
|   a = PGROUNDUP(oldsz); | ||||
|   oldsz = PGROUNDUP(oldsz); | ||||
|   a = oldsz; | ||||
|   for(; a < newsz; a += PGSIZE){ | ||||
|     mem = kalloc(); | ||||
|     if(mem == 0){ | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Robert Morris
						Robert Morris