uiz Space

January 2025 term · Operating Systems · BSCS4022

Operating Systems Quiz 1: 23 February 2025 (January 2025 term)

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.

Questions
19
Marks
50
Duration
120 min
MCQ
17
MSQ
2

Updated

Official paper: IIT M IMPROVEMENT AN EXAM QIM2 23 Feb 2025 · No negative marking.

Question 1

+3 marksOne correct option

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?

  1. A

    0x400053FF

  2. B

    0x40005400

  3. C

    0x400052FF

  4. D

    0x40004FFF

Show answer

Correct answer

  • B

    0x40005400

Question 2

+3 marksOne correct option

Consider the following code snippet:

c
#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?

  1. A

    Sizes of all the registers are 4-byte.

  2. B

    Sizes of ‘config_reg‘, ‘status_reg‘, and ‘counter_reg‘ are 4-byte, 1-byte, and 2- byte respectively.

  3. C

    Sizes of ‘config_reg‘, ‘status_reg‘, and ‘counter_reg‘ are 2-byte, 1-byte, and 2- byte respectively.

  4. D

    Sizes of ‘config_reg‘, ‘status_reg‘, and ‘counter_reg‘ are 1-byte, 2-byte, and 4- byte respectively.

Show answer

Correct answer

  • B

    Sizes of ‘config_reg‘, ‘status_reg‘, and ‘counter_reg‘ are 4-byte, 1-byte, and 2- byte respectively.

Question 3

+3 marksOne correct option

What does the following ‘xv6‘ code snippet accomplish?

c
int pid;
pid = fork();
if (pid == 0) {
execlp("ls", "ls", "-l", NULL);
exit(0);
} else if (pid > 0) {
int status;
wait(&status);
}
  1. A

    Both the parent and child processes execute the ‘ls‘ command concurrently.

  2. B

    The child process executes the ‘ls -l‘ command, and the parent process waits for it to complete.

  3. C

    The parent process executes the ‘ls -l‘ command, and the child process terminates.

  4. D

    None of these

Show answer

Correct answer

  • B

    The child process executes the ‘ls -l‘ command, and the parent process waits for it to complete.

Question 4

+3 marksOne correct option

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.

  1. A

    (i) → (ii) → (iii) → (iv)

  2. B

    (i) → (iii) → (ii) → (iv)

  3. C

    (ii) → (i) → (iii) → (iv)

  4. D

    (ii) → (i) → (iv) → (iii)

Show answer

Correct answer

  • A

    (i) → (ii) → (iii) → (iv)

Question 5

+3 marksOne correct option

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?

  1. A

    Process A

  2. B

    Process B

  3. C

    Process C

  4. D

    Process init

  5. E

    None of these

Show answer

Correct answer

  • C

    Process C

Question 6

+3 marksOne correct option

Consider the following code snippet for the syscall function in kernel/syscall.c:

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?

  1. A

    The base address of the process’s memory.

  2. B

    The number of system calls handled by the kernel.

  3. C

    The number identifying the requested system call.

  4. D

    The priority level of the process.

Show answer

Correct answer

  • C

    The number identifying the requested system call.

Question 7

+4 marksOne correct option

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?

  1. A

    64 KB

  2. B

    16 KB

  3. C

    8 KB

  4. D

    32 KB

Show answer

Correct answer

  • B

    16 KB

Question 8

+4 marksOne correct option

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?

  1. A

    2¹⁶ frames

  2. B

    2¹⁵ frames

  3. C

    2¹³ frames

  4. D

    2¹⁷ frames

Show answer

Correct answer

  • C

    2¹³ frames

Question 9

+4 marksOne correct option

What could be the possible output of the following program?

c
#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;
}
  1. A

    Parent 1: 20
    Child 1: 15
    Child 2: 30
    Parent 2: 50

  2. B

    Child 1: 25
    Parent 1: 20
    Parent 2: 50
    Child 2: 30

  3. C

    Parent 1: 20
    Parent 2: 50
    Child 1: 20
    Child 2: 50

  4. D

    Child 1: 15
    Parent 1: 25
    Parent 2: 50
    Child 2: 35

Show answer

Correct answer

  • A

    Parent 1: 20
    Child 1: 15
    Child 2: 30
    Parent 2: 50

Question 10

+2 marksOne correct option

What is deadlock in an operating system?

  1. A

    Processes waiting for input from the user.

  2. B

    A process that uses all available CPU resources.

  3. C

    A situation where two or more processes are blocked forever.

  4. D

    Processes consuming more memory than allocated.

Show answer

Correct answer

  • C

    A situation where two or more processes are blocked forever.

Question 11

+2 marksOne correct option
  1. A

    Initializing the kernel’s virtual memory

  2. B

    Initializing user-level page tables

  3. C

    Configuring the interrupt vector table

  4. D

    Managing process scheduling

Show answer

Correct answer

  • A

    Initializing the kernel’s virtual memory

Question 12

+2 marksOne correct option
  1. A

    TRUE

  2. B

    FALSE

Show answer

Correct answer

  • B

    FALSE

Question 13

+2 marksOne correct option
  1. A

    A process that is waiting for an event or resource to become available.

  2. B

    A process that is temporarily inactive while waiting for some condition to be met.

  3. C

    A process that has finished execution and is ready to be removed from the process table.

  4. D

    None of these

Show answer

Correct answer

  • B

    A process that is temporarily inactive while waiting for some condition to be met.

Question 14

+2 marksOne correct option

In the xv6 operating system, if a process is waiting for I/O to complete, what will be the state transition of the process?

  1. A

    Running → Runnable

  2. B

    Running → Sleeping

  3. C

    Runnable → Unused

  4. D

    State remains unchanged

Show answer

Correct answer

  • B

    Running → Sleeping

Question 15

+2 marksOne correct option

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?

  1. A

    wait-fork-exec

  2. B

    exec-wait-fork

  3. C

    fork-exec-wait

  4. D

    exec-fork-wait

Show answer

Correct answer

  • C

    fork-exec-wait

Question 16

+1 markOne correct option
  1. A

    TRUE

  2. B

    FALSE

Show answer

Correct answer

  • A

    TRUE

Question 17

+1 markOne correct option

When a process invokes the exec system call, which components in the Process Control Block (PCB) remain unchanged?

  1. A

    Page table entries

  2. B

    Process identifier (PID)

  3. C

    The value of the program counter

  4. D

    File descriptor table and memory information.

Show answer

Correct answer

  • B

    Process identifier (PID)

Question 18

+3 marksOne or more correct options

Which of the following actions are performed by userinit?

The source code of userinit is given below for reference.

c
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;
12
13 // prepare for the very first "return" from kernel to user.
14 p->trapframe->epc = 0; // user program counter
15 p->trapframe->sp = PGSIZE; // user stack pointer
16
17 safestrcpy(p->name, "initcode", sizeof(p->name));
18 p->cwd = namei("/");
19
20 p->state = RUNNABLE;
21
22 release(&p->lock);
23 }

Select all that apply.

  1. A
  2. B
  3. C
  4. D
  5. E
Show answer

Correct answers

  • A
  • D

Question 19

+3 marksOne or more correct options

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.

Select all that apply.

  1. A

    Process P1 is in the RUNNING state.

  2. B

    Process P1 is in the SLEEPING state.

  3. C

    Process P2 is in the RUNNABLE state.

  4. D

    Process P2 is in the ZOMBIE state.

  5. E

    Process P3 is in the RUNNING state.

  6. F

    Process P4 is in the SLEEPING state.

  7. G

    Process P4 is in the RUNNABLE state.

Show answer

Correct answers

  • B

    Process P1 is in the SLEEPING state.

  • D

    Process P2 is in the ZOMBIE state.

  • E

    Process P3 is in the RUNNING state.

  • G

    Process P4 is in the RUNNABLE state.