Question 1
If the memory map for a device starts from the offset 0x40005000 and has a size of 1024 bytes in a 32-bit addressing scheme, what will be the last address in the memory map?
0x400053FF
0x40005400
0x400052FF
0x40004FFF

The IIT Madras BS Operating Systems (Operating Systems) Quiz 1 paper sat on 23 Feb 2025, in the January 2025 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.
If the memory map for a device starts from the offset 0x40005000 and has a size of 1024 bytes in a 32-bit addressing scheme, what will be the last address in the memory map?
0x400053FF
0x40005400
0x400052FF
0x40004FFF
Correct answer
0x40005400
Consider the following code snippet:
#define TIMER_BASE 0x40010000
void configure_timer(){ uint32_t *config_reg = (uint32_t*)(TIMER_BASE + 0x00); uint8_t *status_reg = (uint8_t*)(TIMER_BASE + 0x04); uint16_t *counter_reg = (uint16_t*)(TIMER_BASE + 0x08);
*config_reg = 0x1; while((*status_reg & 0x1) == 0); *counter_reg = 0xFFFF;}What are the sizes of the config_reg, status_reg, and counter_reg registers, respectively?
Sizes of all the registers are 4-byte.
Sizes of ‘config_reg‘, ‘status_reg‘, and ‘counter_reg‘ are 4-byte, 1-byte, and 2- byte respectively.
Sizes of ‘config_reg‘, ‘status_reg‘, and ‘counter_reg‘ are 2-byte, 1-byte, and 2- byte respectively.
Sizes of ‘config_reg‘, ‘status_reg‘, and ‘counter_reg‘ are 1-byte, 2-byte, and 4- byte respectively.
Correct answer
Sizes of ‘config_reg‘, ‘status_reg‘, and ‘counter_reg‘ are 4-byte, 1-byte, and 2- byte respectively.
What does the following ‘xv6‘ code snippet accomplish?
int pid;
pid = fork();if (pid == 0) { execlp("ls", "ls", "-l", NULL); exit(0);} else if (pid > 0) { int status; wait(&status);}Both the parent and child processes execute the ‘ls‘ command concurrently.
The child process executes the ‘ls -l‘ command, and the parent process waits for it to complete.
The parent process executes the ‘ls -l‘ command, and the child process terminates.
None of these
Correct answer
The child process executes the ‘ls -l‘ command, and the parent process waits for it to complete.
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 A that forks process B, and process B forks process C. Process A terminates, and process B continues to execute while process C forks a new process D. What is the parent process of D?
Process A
Process B
Process C
Process init
None of these
Correct answer
Process C
Consider the following code snippet for the syscall function in kernel/syscall.c:
1 void 2 syscall(void) 3 { 4 int syscall_num; 5 struct proc *p = myproc(); 6 7 syscall_num = p->tf->a6; 8 if(syscall_num > 0 && syscall_num < MAX_SYSCALLS && syscalls[syscall_num]) { 9 p->tf->a0 = syscalls[syscall_num]();10 } else {11 printf("PID %d (%s): Invalid syscall %d\n",12 p->pid, p->name, syscall_num);13 p->tf->a0 = -1;14 }15 }What does the a6 register in the trapframe represent in this code?
The base address of the process’s memory.
The number of system calls handled by the kernel.
The number identifying the requested system call.
The priority level of the process.
Correct answer
The number identifying the requested system call.
Consider a system with a virtual memory space size of 16GB and a single page table containing 2²⁰ entries. What is the size of each page frame?
64 KB
16 KB
8 KB
32 KB
Correct answer
16 KB
Consider a system with 128 MB of physical memory and a 32-bit virtual address space. Given a page size of 8 KB, what will be the number of frames?
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>
int main() { int x = 10, pid; pid = fork(); if (pid == 0) { x += 5; printf("Child 1: %d\n", x); } else { x += 10; printf("Parent 1: %d\n", x); pid = fork(); if (pid == 0) { x += 20; printf("Child 2: %d\n", x); } else { x += 30; printf("Parent 2: %d\n", x); } } return 0;}Parent 1: 20
Child 1: 15
Child 2: 30
Parent 2: 50
Child 1: 25
Parent 1: 20
Parent 2: 50
Child 2: 30
Parent 1: 20
Parent 2: 50
Child 1: 20
Child 2: 50
Child 1: 15
Parent 1: 25
Parent 2: 50
Child 2: 35
Correct answer
Parent 1: 20
Child 1: 15
Child 2: 30
Parent 2: 50
What is deadlock in an operating system?
Processes waiting for input from the user.
A process that uses all available CPU resources.
A situation where two or more processes are blocked forever.
Processes consuming more memory than allocated.
Correct answer
A situation where two or more processes are blocked forever.
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
TRUE
FALSE
Correct answer
FALSE
A process that is waiting for an event or resource to become available.
A process that is temporarily inactive while waiting for some condition to be met.
A process that has finished execution and is ready to be removed from the process table.
None of these
Correct answer
A process that is temporarily inactive while waiting for some condition to be met.
In the xv6 operating system, if a process is waiting for I/O to complete, what will be the state transition of the process?
Running → Runnable
Running → Sleeping
Runnable → Unused
State remains unchanged
Correct answer
Running → Sleeping
Imagine a basic Linux shell that executes the ls -l command. Which of the following lists correctly orders the system calls initiated by the shell, starting from the moment the user enters this command until the shell resumes and prompts the user for their next input?
wait-fork-exec
exec-wait-fork
fork-exec-wait
exec-fork-wait
Correct answer
fork-exec-wait
TRUE
FALSE
Correct answer
TRUE
When a process invokes the exec system call, which components in the Process Control Block (PCB) remain unchanged?
Page table entries
Process identifier (PID)
The value of the program counter
File descriptor table and memory information.
Correct answer
Process identifier (PID)
Which of the following actions are performed by userinit?
The source code of userinit is given below for reference.
1 void userinit(void) 2 { 3 struct proc *p; 4 5 p = allocproc(); 6 initproc = p; 7 8 // allocate one user page and copy initcode's instructions 9 // and data into it.10 uvmfirst(p->pagetable, initcode, sizeof(initcode));11 p->sz = PGSIZE;1213 // prepare for the very first "return" from kernel to user.14 p->trapframe->epc = 0; // user program counter15 p->trapframe->sp = PGSIZE; // user stack pointer1617 safestrcpy(p->name, "initcode", sizeof(p->name));18 p->cwd = namei("/");1920 p->state = RUNNABLE;2122 release(&p->lock);23 }Correct answers
Assume the following processes are in various states:
• Process P1 is waiting for I/O to complete.
• Process P2 has completed execution, but its parent has not yet collected its exit status. • Process P3 is actively running on the CPU.
• Process P4 is ready to execute but is waiting for the CPU.
Select all the correct statements about the states of the processes.
Process P1 is in the RUNNING state.
Process P1 is in the SLEEPING state.
Process P2 is in the RUNNABLE state.
Process P2 is in the ZOMBIE state.
Process P3 is in the RUNNING state.
Process P4 is in the SLEEPING state.
Process P4 is in the RUNNABLE state.
Correct answers
Process P1 is in the SLEEPING state.
Process P2 is in the ZOMBIE state.
Process P3 is in the RUNNING state.
Process P4 is in the RUNNABLE state.