Question 17
Which of the following actions are performed by userinit in xv6?
The source code of userinit is given below for reference.
void userinit(void){ struct proc *p;
p = allocproc(); initproc = p;
// allocate one user page and copy initcode's instructions // and data into it. uvmfirst(p->pagetable, initcode, sizeof(initcode)); p->sz = PGSIZE;
// prepare for the very first "return" from kernel to user. p->trapframe->epc = 0; // user program counter p->trapframe->sp = PGSIZE; // user stack pointer
safestrcpy(p->name, "initcode", sizeof(p->name)); p->cwd = namei("/");
p->state = RUNNABLE;
release(&p->lock);}