Question 1
State True or False
In RISC-V, during system calls, the mstatus register stores the current mode of operation of the processor.
TRUE
FALSE

The IIT Madras BS Operating Systems (Operating Systems) Quiz 1 paper sat on 7 Jul 2024, in the May 2024 term: 19 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.
State True or False
In RISC-V, during system calls, the mstatus register stores the current mode of operation of the processor.
TRUE
FALSE
Correct answer
TRUE
The ecall instruction in the xv6 operating system facilitates the transition of the CPU from user mode to supervisor mode.
TRUE
FALSE
Correct answer
TRUE
What is a race condition in an operating system?
Processes racing for CPU resources.
Concurrent access leading to unpredictable results
Incompatible hardware configurations.
System instability due to competing tasks.
Correct answer
Concurrent access leading to unpredictable results
What is the primary purpose of the kvminit function in the xv6 operating system?
Initializing the kernel’s virtual memory
Initializing user-level page tables
Configuring the interrupt vector table
Managing process scheduling
Correct answer
Initializing the kernel’s virtual memory
State True or False.
The init process, being the first process created by the system, can exit using the exit system call.
TRUE
FALSE
Correct answer
FALSE
In the context of xv6 operating systems, what does the zombie state of a process refer to?
A process that has terminated, but whose resources have not yet been deallocated by the operating system.
A process that is suspended and waiting for user input.
A process that is ready to run but is waiting for CPU time.
None of these
Correct answer
A process that has terminated, but whose resources have not yet been deallocated by the operating system.
In the xv6 operating system, if a timer interrupt occurs while a process is executing, what will be the state transition of the process?
Running → Sleeping
Running → Unused
Running → Runnable
State remains unchanged
Correct answer
Running → Runnable
The number of CPUs supported by xv6 is 64.
The size of each struct proc is 64 bytes.
The array proc can dynamically resize to handle more than 64 processes.
The system can handle a maximum of 64 processes simultaneously.
Correct answer
The system can handle a maximum of 64 processes simultaneously.
If the memory map for a device starts from the offset 0x30004000 and has a size of 512 bytes in a 32-bit addressing scheme, what will be the last address in the memory map?
0x30004100
0x300041FF
0x30004200
0x30003FFF
Correct answer
0x300041FF
Consider the code segment given below.
#define PERIPHERAL_BASE 0x40000000
void init_peripheral(){ uint16_t *control_reg = (uint16_t*)(PERIPHERAL_BASE + 4); *control_reg = 0x1234;}
uint32_t read_data(){ uint32_t *data_reg = (uint32_t*)(PERIPHERAL_BASE + 8); uint8_t *status_reg = (uint8_t*)(PERIPHERAL_BASE + 12); while((*status_reg & 0x2) == 0); return *data_reg;}Identify the correct sizes of control register, data register, and status register.
Sizes of all the registers are 4-byte.
Sizes of control register, data register, and status register are 2-byte, 4-byte, and 1-byte respectively.
Sizes of control register, data register, and status register are 2-byte, 4-byte, and 2-byte respectively.
Sizes of control register, data register, and status register are 16-byte, 32-byte, and 8-byte respectively.
Correct answer
Sizes of control register, data register, and status register are 2-byte, 4-byte, and 1-byte respectively.
What does the following xv6 code snippet accomplish?
int pid;
pid = fork();if (pid > 0){ pid = wait();} else{ execlp("pwd", "", NULL); exit(0);}Both the parent and child processes execute the pwd command concurrently.
The parent process waits for the child process to finish executing the pwd command.
The parent process executes the pwd command and then waits for the child process to finish.
None of these
Correct answer
The parent process waits for the child process to finish executing the pwd command.
What is the correct sequence of setting up first user process?
(i) Find an unused proc entry.
(ii) Create trapframe.
(iii) Create empty user process page table.
(iv) Create context for process.
(i) → (ii) → (iii) → (iv)
(i) → (iii) → (ii) → (iv)
(ii) → (i) → (iii) → (iv)
(ii) → (i) → (iv) → (iii)
Correct answer
(i) → (ii) → (iii) → (iv)
Consider a process P1 that forks P2, P2 forks P3, and P3 forks P4. P1 and P2 continue to execute while P3 terminates. Now, what is the parent process of P4?
Process P1
Process P2
Process init
None of these
Correct answer
Process init
Consider the below code for the syscall function in kernel/syscall.c.
1 void 2 syscall(void) 3 { 4 int num; 5 struct proc *p = myproc(); 6 7 num = p->tf->a7; 8 if(num > 0 && num < NELEM(syscalls) && syscalls[num]) { 9 p->tf->a0 = syscalls[num]();10 } else {11 printf("%d %s: unknown sys call %d\n",12 p->pid, p->name, num);13 p->tf->a0 = -1;14 }15 }What value is stored in the a7 register of the trapframe?
The return address of the user space
The number that is returned to the user space.
The number that identifies the system call.
The number that identifies the process
Correct answer
The number that identifies the system call.
Which of the following actions are performed by userinit?
It creates a page directory.
It invokes procinit.
It sets the process to a sleeping state.
It allocates a process id and trapframe.
It creates a user stack at 0X0.
Correct answers
It creates a page directory.
It allocates a process id and trapframe.
Assume Process P2 and Process P4 are waiting for an input, Process P1 is running, and Process P3 was running before Process P1 and is now waiting for its turn to run. Select all the correct statements about the states of the processes.
Process P2 is in the RUNNABLE state
Process P4 is in the SLEEPING state.
Process P1 is in the RUNNING state.
Process P3 is in the SLEEPING state.
Process P3 is in the RUNNABLE state.
Correct answers
Process P4 is in the SLEEPING state.
Process P1 is in the RUNNING state.
Process P3 is in the RUNNABLE state.
Consider a system with a virtual memory space size of 8 GB and a single page table with 2¹⁸ entries. What is the size of each page frame?
32 MB
64 KB
16 KB
32 KB
Correct answer
32 KB
Consider a system with 64 MB of physical memory and a 32-bit virtual address space. Given a page size of 4 KB, what will be the number of frames?
2¹⁶ frames
2¹⁴ frames
2¹² frames
2¹⁸ frames
Correct answer
2¹⁴ frames
Which of the following can be possible output of the following lines of code?
#include <stdio.h>#include <stdlib.h>
int main() { int a, pid; a = 20; pid = fork(); if (pid == 0) { printf("Parent\t %d\n", a); } else { printf("Child\t %d\n", a); a = 15; printf("Child\t %d\n", a); } return 0;}Child 20
Child 15
Parent 15
Child 20
Child 15
Parent 20
Parent 20
Child 20
Child 15
Parent 15
Child 20
Child 15
Correct answers
Child 20
Child 15
Parent 20
Parent 20
Child 20
Child 15