diff options
Diffstat (limited to 'kernel/proc.c')
-rw-r--r-- | kernel/proc.c | 32 |
1 files changed, 16 insertions, 16 deletions
diff --git a/kernel/proc.c b/kernel/proc.c index bbf3af0..cf7f260 100644 --- a/kernel/proc.c +++ b/kernel/proc.c @@ -20,6 +20,7 @@ static void wakeup1(struct proc *chan); extern char trampoline[]; // trampoline.S +// initialize the proc table at boot time. void procinit(void) { @@ -106,7 +107,7 @@ found: p->pid = allocpid(); // Allocate a trapframe page. - if((p->tf = (struct trapframe *)kalloc()) == 0){ + if((p->trapframe = (struct trapframe *)kalloc()) == 0){ release(&p->lock); return 0; } @@ -116,7 +117,7 @@ found: // Set up new context to start executing at forkret, // which returns to user space. - memset(&p->context, 0, sizeof p->context); + memset(&p->context, 0, sizeof(p->context)); p->context.ra = (uint64)forkret; p->context.sp = p->kstack + PGSIZE; @@ -129,9 +130,9 @@ found: static void freeproc(struct proc *p) { - if(p->tf) - kfree((void*)p->tf); - p->tf = 0; + if(p->trapframe) + kfree((void*)p->trapframe); + p->trapframe = 0; if(p->pagetable) proc_freepagetable(p->pagetable, p->sz); p->pagetable = 0; @@ -145,8 +146,8 @@ freeproc(struct proc *p) p->state = UNUSED; } -// Create a page table for a given process, -// with no user pages, but with trampoline pages. +// Create a user page table for a given process, +// with no user memory, but with trampoline pages. pagetable_t proc_pagetable(struct proc *p) { @@ -164,7 +165,7 @@ proc_pagetable(struct proc *p) // map the trapframe just below TRAMPOLINE, for trampoline.S. mappages(pagetable, TRAPFRAME, PGSIZE, - (uint64)(p->tf), PTE_R | PTE_W); + (uint64)(p->trapframe), PTE_R | PTE_W); return pagetable; } @@ -176,8 +177,7 @@ proc_freepagetable(pagetable_t pagetable, uint64 sz) { uvmunmap(pagetable, TRAMPOLINE, PGSIZE, 0); uvmunmap(pagetable, TRAPFRAME, PGSIZE, 0); - if(sz > 0) - uvmfree(pagetable, sz); + uvmfree(pagetable, sz); } // a user program that calls exec("/init") @@ -207,8 +207,8 @@ userinit(void) p->sz = PGSIZE; // prepare for the very first "return" from kernel to user. - p->tf->epc = 0; // user program counter - p->tf->sp = PGSIZE; // user stack pointer + p->trapframe->epc = 0; // user program counter + p->trapframe->sp = PGSIZE; // user stack pointer safestrcpy(p->name, "initcode", sizeof(p->name)); p->cwd = namei("/"); @@ -263,10 +263,10 @@ fork(void) np->parent = p; // copy saved user registers. - *(np->tf) = *(p->tf); + *(np->trapframe) = *(p->trapframe); // Cause fork to return 0 in the child. - np->tf->a0 = 0; + np->trapframe->a0 = 0; // increment reference counts on open file descriptors. for(i = 0; i < NOFILE; i++) @@ -457,7 +457,7 @@ scheduler(void) // before jumping back to us. p->state = RUNNING; c->proc = p; - swtch(&c->scheduler, &p->context); + swtch(&c->context, &p->context); // Process is done running for now. // It should have changed its p->state before coming back. @@ -491,7 +491,7 @@ sched(void) panic("sched interruptible"); intena = mycpu()->intena; - swtch(&p->context, &mycpu()->scheduler); + swtch(&p->context, &mycpu()->context); mycpu()->intena = intena; } |