Quiz Space

Operating Systems · Quiz 1 · 26 Oct 2025 · September 2025 term

Question 17: Which of the following actions are performed by userinit…

Question 17

+3 marksOne or more correct options

Which of the following actions are performed by userinit in xv6?

The source code of userinit is given below for reference.

c
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);
}

Select all that apply.

  1. A
  2. B
  3. C
  4. D
  5. E
Show answer

Correct answers

  • B
  • E

Question 17 of 18 in the IIT Madras BS Operating Systems (Operating Systems) Quiz 1 paper sat on 26 Oct 2025, in the September 2025 term (IIT M IMPROVEMENT AN EXAM QIB2 26 Oct 2025). It carries 3 marks.

More questions from this paper

  1. Q1Figure question
  2. Q2In RISC-V, during system calls, which register stores the current mode of operation of the processor?
  3. Q3Figure question
  4. Q4In the xv6 operating system, suppose a process is running and a timer interrupt occurs. What will be the transition for…
  5. Q5In the xv6 operating system, when a process calls exit(), what will be the state transition of the process?
  6. Q6Which of the following sequences of functions determines the steps for the execution of the first process initcode in t…
  7. Q7If the memory map for a device starts from the offset 0x20001000 and has a size of 2048 bytes in a 32-bit addressing sc…
  8. Q8Consider the following code snippet: What are the access sizes of the data_reg and dir_reg registers, respectively?
  9. Q9What will be the output behavior of the following xv6 code snippet?
  10. Q10Figure question
  11. Q11Figure question
  12. Q12Consider the following code snippet for the syscall function in kernel/syscall.c (RISC-V xv6): What does the a7 registe…
  13. Q13Figure question
  14. Q14Figure question
  15. Q15Consider a system with 64 MB of physical memory and a 32-bit virtual address space. Given a page size of 16 KB, what wi…
  16. Q16What could be the possible output of the following program?
  17. Q18Consider the following processes in an xv6-like operating system: Process Q1 has been created but has not yet been sche…