Question 23
Consider the following code for allocproc.
1 static struct proc* 2 allocproc(void) 3 { 4 struct proc *p; 5 6 for(p = proc; p < &proc[NPROC]; p++) { 7 acquire(&p->lock); 8 if(p->state == UNUSED) { 9 goto found;10 } else {11 release(&p->lock);12 }13 }14 return 0;1516 found:17 p->pid = allocpid();18 p->state = USED;1920 if((p->trapframe = (struct trapframe *)kalloc()) == 0){21 freeproc(p);22 release(&p->lock);23 return 0;24 }2526 p->pagetable = proc_pagetable(p);27 if(p->pagetable == 0){28 freeproc(p);29 release(&p->lock);30 return 0;31 }3233 memset(&p->context, 0, sizeof(p->context));34 p->context.ra = (uint64)forkret;35 p->context.sp = p->kstack + PGSIZE;3637 return p;38 }Assuming no context switch occur during allocproc, which of the return statements in the above code gets executed if the freelist is empty when allocproc is called?
line 14
line 23
line 30
line 37