Question 1
TRUE
FALSE

The IIT Madras BS Operating Systems (Operating Systems) Quiz 1 paper sat on 26 Oct 2025, in the September 2025 term: 18 questions for 50 marks in 120 minutes. Every question is below with its answer. Take it as a timed mock test to be marked, or read it through first.
TRUE
FALSE
Correct answer
TRUE
In RISC-V, during system calls, which register stores the current mode of operation of the processor?
Correct answer
TRUE
FALSE
Correct answer
TRUE
In the xv6 operating system, suppose a process is running and a timer interrupt occurs. What will be the transition for the process state?
Running → Sleeping
Running → Runnable
Running → Unused
State remain unchanged
Correct answer
Running → Runnable
In the xv6 operating system, when a process calls exit(), what will be the state transition of the process?
Running → Sleeping
Runnable → Unused
Running → Zombie
Sleeping → Runnable
Correct answer
Running → Zombie
Which of the following sequences of functions determines the steps for the execution of the first process initcode in the xv6 operating system?
Correct answer
If the memory map for a device starts from the offset 0x20001000 and has a size of 2048 bytes in a 32-bit addressing scheme, what will be the last address in the memory map?
0x200017FF
0x20001800
0x200016FF
0x20000FFF
Correct answer
0x200017FF
Consider the following code snippet:
#define GPIO_PORTA_BASE 0x50000000
void write_gpio(){ uint16_t *data_reg = (uint16_t*)(GPIO_PORTA_BASE + 0x10); uint32_t *dir_reg = (uint32_t*)(GPIO_PORTA_BASE + 0x14);
*dir_reg = 0xFF; // Configure lower 8 pins as output *data_reg = 0xAA55; // Write pattern to port}What are the access sizes of the data_reg and dir_reg registers, respectively?
Correct answer
What will be the output behavior of the following xv6 code snippet?
int pid;
pid = fork();if (pid == 0) { printf(1, "Child process\n"); exit(0);} else if (pid > 0) { printf(1, "Parent process\n"); wait(0);}Correct answer
(i) → (ii) → (iii) → (iv)
(i) → (iii) → (ii) → (iv)
(ii) → (i) → (iii) → (iv)
(iii) → (i) → (ii) → (iv)
Correct answer
(i) → (ii) → (iii) → (iv)
Correct answer
Consider the following code snippet for the syscall function in kernel/syscall.c (RISC-V xv6):
voidsyscall(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?
The base address of the process stack.
The return value of the system call.
The number of arguments passed to the system call.
The number identifying the requested system call.
Correct answer
The number identifying the requested system call.
Correct answer
2 KB
4 KB
8 KB
16 KB
Correct answer
4 KB
Consider a system with 64 MB of physical memory and a 32-bit virtual address space. Given a page size of 16 KB, what will be the maximum number of page frames that can be present in RAM?
2¹⁰ frames
2¹¹ frames
2¹³ frames
2¹² frames
Correct answer
2¹² frames
What could be the possible output of the following program?
#include <stdio.h>#include <stdlib.h>#include <unistd.h>
int main() { int x = 5, pid; pid = fork(); if (pid == 0) { x += 3; printf("Child 1: %d\n", x); } else { x += 7; printf("Parent 1: %d\n", x); pid = fork(); if (pid == 0) { x += 10; printf("Child 2: %d\n", x); } else { x += 15; printf("Parent 2: %d\n", x); } } return 0;}Correct answer
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);}Correct answers
Consider the following processes in an xv6-like operating system:
Select all the correct statements about the states of the processes.
Process Q1 is in the RUNNABLE state.
Process Q2 is in the RUNNING state.
Process Q3 is in the RUNNABLE state.
Process Q3 is in the SLEEPING state.
Process Q4 is in the ZOMBIE state.
Process Q4 is in the SLEEPING state.
Correct answers
Process Q1 is in the RUNNABLE state.
Process Q2 is in the RUNNING state.
Process Q3 is in the SLEEPING state.