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