Quiz Space

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

Question 12: Consider the following code snippet for the syscall func…

Question 12

+3 marksOne correct option

Consider the following code snippet for the syscall function in kernel/syscall.c (RISC-V xv6):

c
void
syscall(void)
{
int syscall_num;
struct proc *p = myproc();
syscall_num = p->trapframe->a7; // system call number
if(syscall_num > 0 && syscall_num < MAX_SYSCALLS && syscalls[syscall_num]) {
p->trapframe->a0 = syscalls[syscall_num]();
} else {
printf("PID %d (%s): Invalid syscall %d\n",
p->pid, p->name, syscall_num);
p->trapframe->a0 = -1;
}
}

What does the a7 register in the trapframe represent in this code?

  1. A

    The base address of the process stack.

  2. B

    The return value of the system call.

  3. C

    The number of arguments passed to the system call.

  4. D

    The number identifying the requested system call.

Show answer

Correct answer

  • D

    The number identifying the requested system call.

Question 12 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. Q13Figure question
  13. Q14Figure question
  14. 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…
  15. Q16What could be the possible output of the following program?
  16. Q17Which of the following actions are performed by userinit in xv6? The source code of userinit is given below for referen…
  17. Q18Consider the following processes in an xv6-like operating system: Process Q1 has been created but has not yet been sche…