Question 1
In monolithic kernels, there is direct communication between modules in the kernel by procedure calls.
TRUE
FALSE

The IIT Madras BS Operating Systems (Operating Systems) Quiz 1 paper sat on 25 Feb 2024, in the January 2024 term: 22 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.
In monolithic kernels, there is direct communication between modules in the kernel by procedure calls.
TRUE
FALSE
Correct answer
TRUE
The _entry function in an operating system kernel like xv6 is called by each CPU core individually during the boot process, and it initializes the stack for each CPU core separately.
TRUE
FALSE
Correct answer
TRUE
“Daemons are deliberate orphan processes that become detached from user sessions and operate in the background.”
TRUE
FALSE
Correct answer
TRUE
If the memory map for the interrupt controller starts from the offset 0x20000000 and has a size of 256 bytes in a 32-bit addressing scheme then what will be the last address in the memory map?
0x200000FF
0x20000100
0x200001FF
0x20000200
Correct answer
0x200000FF
Which instruction in the xv6 operating system facilitates the transition of the CPU from user mode to supervisor mode?
jmp
syscall
ecall
None of these
Correct answer
ecall
It is the memory address where the proc array begins.
It is the total number of processes launched since the system boot.
It is the number of CPU cores available to xv6.
It is the maximum number of concurrent processes supported.
Correct answer
It is the maximum number of concurrent processes supported.
Managing process states
Handling timer interrupts
Managing system resources
Storing the return address for function calls
Correct answer
Storing the return address for function calls
What is the correct sequence of tasks that takes place as part of memory initializationof the xv6 kernel before turning on paging?
(i) Creation of page frames
(ii) Creation of page tables for kernel
(iii) Add each chunk of 4KB physical memory to the freelist
(iv) Set the page table bits in the satp register
(i) → (ii) → (iii) → (iv)
(i) → (iii) → (ii) → (iv)
(ii) → (i) → (iii) → (iv)
(ii) → (i) → (iv) → (iii)
Correct answer
(i) → (iii) → (ii) → (iv)
Select the incorrect statements regarding the exit function.
The exit function sets the state of the current process to ZOMBIE.
The exit function reparents the child processes to the init process using the reparent function.
The exit function changes the context of the current process to the parent process by returning the exit status to the wait function of the parent.
The exit function is responsible for closing all the opened files using fileclose function.
Correct answer
The exit function changes the context of the current process to the parent process by returning the exit status to the wait function of the parent.
Select all the incorrect statements regarding the wait function.
wait function runs an infinite loop until all the child processes of the parent are terminated.
wait function returns when it finds a terminated child process.
wait function returns the exit status of the child to the parent.
wait function returns the pid of the terminated child.
Correct answer
wait function runs an infinite loop until all the child processes of the parent are terminated.
stack0 + 3 + 4 * 1024
stack0 + 3 * 4* 1024
stack0 + 2 * 4 * 1024
stack0 + 2 + 4 * 1024
Correct answer
stack0 + 2 * 4 * 1024
Consider the size of the virtual memory space is 4 GB, and the number of entries in the page table is 2²¹. What is the size of each page frame?
3MB
3KB
6KB
6MB
Correct answer
3KB
Consider the following lines of code. Identify the TRUE statements.
int i=0, pid;pid = fork();if (pid > 0){ sleep(1); printf("parent : %d\n", i); wait();} else{ i = i + 1; printf("child : %d\n", i);}Figure 1:
(i) Output is parent : 0 child : 1
(ii) In the parent process, fork returns child pid, and in the child process, fork returns 0 (iii) wait returns the PID of an exiting parent process
(iv) When fork is called, all pages are easily shared between parent and child by copying the parent’s page tables
(i), (ii), and (iii)
(i), (iii), and (iv)
(i), (ii), and (iv)
(ii), (iii), and (iv)
Correct answer
(i), (ii), and (iv)
Find the correct match for the following functions.
Correct answer
Consider a system with 32 MB of physical memory and a 32-bit virtual address space. Given a page size of 2 KB, what will be the number of frames?
2³² frames
2¹⁴ frames
2²⁰ frames
2¹⁵ frames
Correct answer
2¹⁴ frames
Assume process A is waiting for an input, process B is running, and process C was running before process B and is now waiting for its turn to run. Select all the correct statements from below.
A is in RUNNABLE state
A is in SLEEPING state
C is in RUNNABLE state
C is in SLEEPING state
Correct answers
A is in SLEEPING state
C is in RUNNABLE state
Select all the correct statements about the first process in xv6 (sbin/init).
init process uses fork system call to create child processes and loads the other programs using exec system call in the child processes.
The init process uses the exec system call to create child processes.
init process is created by a fork system call using ecall instruction.
init process is created by an exec system call using ecall instruction.
Correct answers
init process uses fork system call to create child processes and loads the other programs using exec system call in the child processes.
init process is created by an exec system call using ecall instruction.
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 = 30; pid = fork(); if(pid == 0) { printf("Parent\t %d\n", a); } else { printf("Child\t %d\n", a); a = 25; printf("Child\t %d\n", a); } return 0;}Figure 2:
Child 30
Child 25
Parent 30
Child 30
Child 25
Parent 25
Parent 30
Child 30
Child 25
Parent 25
Child 30
Child 25
Correct answers
Child 30
Child 25
Parent 30
Parent 30
Child 30
Child 25
Consider the code segment (for xv6) given below.
1 #define UART_BASE 0xA0004000 2 3 void init_uart(){ 4 u16 *baud_reg = (u16*)UART_BASE; 5 *baud_reg = 0x7D; 6 } 7 u32 read_uart(){ 8 u32 *rx_reg = (u32*)(UART_BASE + 8); 9 u8 *status_reg = (u8*)(UART_BASE + 12);10 while((*status_reg & 0x4) == 0);11 return *rx_reg;12 }In the code above baud_reg, rx_reg, and status_reg are the pointers to baud register, RX register and status register, respectively.
Based on the above data, answer the given subquestions.
The base address is 0x00000000, and content is 0x0000.
The base address is 0x00000000, and content is 0x7D.
The base address is 0xA0004000, and content is 0x0000.
The base address is 0xA0004000, and content is 0x007D.
Correct answer
The base address is 0xA0004000, and content is 0x007D.
Consider the code segment (for xv6) given below.
1 #define UART_BASE 0xA0004000 2 3 void init_uart(){ 4 u16 *baud_reg = (u16*)UART_BASE; 5 *baud_reg = 0x7D; 6 } 7 u32 read_uart(){ 8 u32 *rx_reg = (u32*)(UART_BASE + 8); 9 u8 *status_reg = (u8*)(UART_BASE + 12);10 while((*status_reg & 0x4) == 0);11 return *rx_reg;12 }In the code above baud_reg, rx_reg, and status_reg are the pointers to baud register, RX register and status register, respectively.
Based on the above data, answer the given subquestions.
Correct answer
Consider the following code for kvminit function in vm. c.
1 void 2 kvminit() 3 { 4 kernel_pagetable = (pagetable_t) kalloc(); 5 memset(kernel_pagetable, 0, PGSIZE); 6 7 kvmmap(UART0, UART0, PGSIZE, PTE_R | PTE_W); 8 9 kvmmap(VIRTION(0), VIRTION(0), PGSIZE, PTE_R | PTE_W);1011 kvmmap(VIRTION(1), VIRTION(1), PGSIZE, PTE_R | PTE_W);1213 kvmmap(CLINT, CLINT, 0x10000, PTE_R | PTE_W);1415 kvmmap(PLIC, PLIC, 0x400000, PTE_R | PTE_W);1617 kvmmap(KERNBASE, KERNBASE, (uint64)etext-KERNBASE, PTE_R | PTE_X);1819 kvmmap((uint64)etext, (uint64)etext, PHYSTOP-(uint64)etext, PTE_R | PTE_W);2021 kvmmap(TRAMPOLINE, (uint64)trampoline, PGSIZE, PTE_R | PTE_X);22 }Based on the above data, answer the given subquestions.
Correct answer: 1024
Consider the following code for kvminit function in vm. c.
1 void 2 kvminit() 3 { 4 kernel_pagetable = (pagetable_t) kalloc(); 5 memset(kernel_pagetable, 0, PGSIZE); 6 7 kvmmap(UART0, UART0, PGSIZE, PTE_R | PTE_W); 8 9 kvmmap(VIRTION(0), VIRTION(0), PGSIZE, PTE_R | PTE_W);1011 kvmmap(VIRTION(1), VIRTION(1), PGSIZE, PTE_R | PTE_W);1213 kvmmap(CLINT, CLINT, 0x10000, PTE_R | PTE_W);1415 kvmmap(PLIC, PLIC, 0x400000, PTE_R | PTE_W);1617 kvmmap(KERNBASE, KERNBASE, (uint64)etext-KERNBASE, PTE_R | PTE_X);1819 kvmmap((uint64)etext, (uint64)etext, PHYSTOP-(uint64)etext, PTE_R | PTE_W);2021 kvmmap(TRAMPOLINE, (uint64)trampoline, PGSIZE, PTE_R | PTE_X);22 }Based on the above data, answer the given subquestions.
What will be the values of the first 5 bits (from the right) of the page table entry after the execution of kvmmap(KERNBASE, KERNBASE, (uint64)etext-KERNBASE, PTE_R |PTE_X); .
01110
10111
01011
10110
Correct answer
01011