diff options
author | Robert Morris <[email protected]> | 2019-06-04 11:31:50 -0400 |
---|---|---|
committer | Robert Morris <[email protected]> | 2019-06-04 11:31:50 -0400 |
commit | cff3ce6e04ce4a353324630df788df21566807a6 (patch) | |
tree | 31040a8262b6de165a2f1d6cc7ead1db33e67a80 | |
parent | 0e131b226336808c135795f5b9d7defc5a58b2ae (diff) | |
download | xv6-labs-cff3ce6e04ce4a353324630df788df21566807a6.tar.gz xv6-labs-cff3ce6e04ce4a353324630df788df21566807a6.tar.bz2 xv6-labs-cff3ce6e04ce4a353324630df788df21566807a6.zip |
more sbrk fixes
-rw-r--r-- | proc.c | 4 | ||||
-rw-r--r-- | syscall.c | 6 | ||||
-rw-r--r-- | sysproc.c | 23 | ||||
-rw-r--r-- | trap.c | 5 | ||||
-rw-r--r-- | vm.c | 7 |
5 files changed, 22 insertions, 23 deletions
@@ -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, @@ -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 @@ -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(); } @@ -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){ |