Merge branch 'riscv-kstack' into riscv

This commit is contained in:
Frans Kaashoek 2019-07-22 13:32:33 -04:00
commit c5d48db045
5 changed files with 43 additions and 14 deletions

View file

@ -26,8 +26,14 @@ procinit(void)
struct proc *p;
initlock(&pid_lock, "nextpid");
for(p = proc; p < &proc[NPROC]; p++)
for(p = proc; p < &proc[NPROC]; p++) {
initlock(&p->lock, "proc");
// Allocate a page for the kernel stack.
char *kstack = (char *) KSTACK((int) (p - proc));
if((p->kstack = map_kstack(kstack)) == 0) {
panic("procinit");
}
}
}
// Must be called with interrupts disabled,
@ -94,16 +100,8 @@ allocproc(void)
found:
p->pid = allocpid();
// Allocate a page for the kernel stack.
if((p->kstack = kalloc()) == 0){
release(&p->lock);
return 0;
}
// Allocate a trapframe page.
if((p->tf = (struct trapframe *)kalloc()) == 0){
kfree(p->kstack);
p->kstack = 0;
release(&p->lock);
return 0;
}
@ -126,9 +124,6 @@ found:
static void
freeproc(struct proc *p)
{
if(p->kstack)
kfree(p->kstack);
p->kstack = 0;
if(p->tf)
kfree((void*)p->tf);
p->tf = 0;
@ -643,4 +638,3 @@ procdump(void)
printf("\n");
}
}