uiz Space

January 2024 term · Operating Systems · BSCS4022

Operating Systems End Term: 28 April 2024 (January 2024 term)

The IIT Madras BS Operating Systems (Operating Systems) End Term paper sat on 28 Apr 2024, in the January 2024 term: 25 questions for 60 marks in 180 minutes. Every question is below with its answer. Take it as a timed mock test to be marked, or read it through first.

Questions
25
Marks
60
Duration
180 min
MCQ
14
MSQ
6
Numerical
5

Updated

Official paper: IIT M DEGREE AN EXAM QDB3 28 Apr 2024 · No negative marking.

Question 1

+2 marksOne correct option

Consider the code segment (for xv6) given below.

c
1 #define UART_BASE 0xA0004000
2 void init_uart(){
3 u16 *baud_reg = (u16*)UART_BASE;
4 *baud_reg = 0x7D;
5 }
6 u32 read_uart(){
7 u32 *rx_reg = (u32*)(UART_BASE + 8);
8 u8 *status_reg = (u8*)(UART_BASE + 12);
9 while((*status_reg & 0x4) == 0);
10 return *rx_reg;
11 }

What is the base address and the end address of the RX register?

  1. A

    The base address is 0xA0004008, and end address is 0xA000400B.

  2. B

    The base address is 0xA0004008, and end address is 0xA000400C.

  3. C

    The base address is 0xA0004008, and end address is 0xA0004012.

  4. D

    The base address is 0xA0004000, and end address is 0xA0004004.

Show answer

Correct answer

  • A

    The base address is 0xA0004008, and end address is 0xA000400B.

Question 2

+2 marksOne correct option

If the memory map of the interrupt controller starts from the offset 0x20000000 and has an address range 128 bytes in a 32-bit addressing scheme then what will be the final address in the memory map?

  1. A

    0x2000007F

  2. B

    0x20000080

  3. C

    0x200001FF

  4. D

    0x20000200

Show answer

Correct answer

  • A

    0x2000007F

Question 3

+2 marksOne correct option

Assume that process A (parent) is (voluntarily) trying to create a daemon process B (child). Statement 1: exit system call must be called by process A.
Statement 2: wait system call must be called by process B. Choose the correct answer from below.

  1. A

    Statement 1 is correct but Statement 2 is incorrect

  2. B

    Statement 2 is correct but Statement 1 is incorrect

  3. C

    Both statements are correct

  4. D

    Both statements are incorrect

Show answer

Correct answer

  • A

    Statement 1 is correct but Statement 2 is incorrect

Question 4

+2 marksOne correct option
  1. A

    uid=0(root), gid=0(root)

  2. B

    uid=1(root), gid=0(root)

  3. C

    uid=0(root), gid=1(root)

  4. D

    uid=1(root), gid=1(root)

Show answer

Correct answer

  • A

    uid=0(root), gid=0(root)

Question 5

+2 marksOne correct option

Consider the program given below.

c
1 void function(int a, int b, int c)
2 {
3 char buffer1[5]
4 char buffer2[10];
5 }
6 void main
7 {
8 function(1,2,3);
9 }

When buffer2[10] = buffer1[0] occurs, the situation is known as ___.

  1. A

    Heap overflow

  2. B

    Buffer overflow

  3. C

    Frame overflow

  4. D

    Stack overflow

Show answer

Correct answer

  • B

    Buffer overflow

Question 6

+2 marksOne correct option

What is the correct sequence of steps that an attacker would do to inject a payload into the stack using buffer overflow vulnerabilty?
(i) Put machine code in string larger than the buffer
(ii) Get machine codes of payload
(iii) Find buffer overflow vulnerability in an application
(iv) Copy large string into buffer

  1. A

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

  2. B

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

  3. C

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

  4. D

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

Show answer

Correct answer

  • D

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

Question 7

+2 marksOne or more correct options

Select all the incorrect statement(s) about CPU cores in the xv6 Operating System.

Select all that apply.

  1. A

    The main function is executed by all CPU cores, and all cores follow the same execution path.

  2. B

    The main function is executed by all CPU cores, but Core 0 follows a different execution path than the other cores.

  3. C

    All cores execute the main function simultaneously.

  4. D

    The other cores wait until Core 0 finishes setting up the main function before continuing their initialization.

Show answer

Correct answers

  • B

    The main function is executed by all CPU cores, but Core 0 follows a different execution path than the other cores.

  • C

    All cores execute the main function simultaneously.

Question 8

+2 marksOne or more correct options

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.

Select all that apply.

  1. A

    A is in RUNNABLE state

  2. B

    A is in SLEEPING state

  3. C

    C is in RUNNABLE state

  4. D

    C is in SLEEPING state

Show answer

Correct answers

  • B

    A is in SLEEPING state

  • C

    C is in RUNNABLE state

Question 9

+2 marksOne or more correct options

Choose all the correct statements about the exec system call.

Select all that apply.

  1. A

    exec system call creates a new child process for the parent.

  2. B

    exec system call loads the program from a ELF file to the memory.

  3. C

    exec system call can accept command line arguments.

  4. D

    exec system call uses fork system call to load the program.

Show answer

Correct answers

  • B

    exec system call loads the program from a ELF file to the memory.

  • C

    exec system call can accept command line arguments.

Question 10

+2 marksOne or more correct options

Assume a trap occurs due to a system call while in usermode. Which of the following functions are not called while handling the trap?

Select all that apply.

  1. A

    devintr

  2. B

    swtch

  3. C

    uservec

  4. D

    userret

Show answer

Correct answers

  • A

    devintr

  • B

    swtch

Question 11

+2 marksOne or more correct options

Choose all the correct statements regarding CLV (Constant Linear Velocity).

Select all that apply.

  1. A

    In CLV, Spindle speed (rpm) varies depending on the position of the head.

  2. B

    It is harder to engineer than CAV.

  3. C

    It allows varying read rates.

  4. D

    It is used in hard disks.

Show answer

Correct answers

  • A

    In CLV, Spindle speed (rpm) varies depending on the position of the head.

  • B

    It is harder to engineer than CAV.

Question 12

+3 marksOne correct option

Consider the size of the virtual memory space is 4 GB, and the size of each page frame is 4 KB. What is the number of entries in the page table?

  1. A

    2²⁰ Bytes

  2. B

    2¹⁰ Bytes

  3. C

    2³⁰ Bytes

  4. D

    None of these

Show answer

Correct answer

  • B

    2¹⁰ Bytes

Question 13

+3 marksOne correct option
  1. A

    Yes, involving P1, P2 and P3.

  2. B

    No, there is no deadlock situation.

  3. C

    Yes, involving P1 and P2.

  4. D

    Yes, involving P2 and P3.

Show answer

Correct answer

  • D

    Yes, involving P2 and P3.

Question 14

+3 marksOne correct option

Consider that the below commands are executed in a shell with root ("/") as the current directory.

bash
mkdir project
cd project
mkdir src tests docs
cd src
echo hello > main.py
cd ..
cd tests
echo hello > test.py
cd ..
cd docs
echo hello > api.md

What is the absolute path of the file main.py?

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

Correct answer

  • C

Question 15

+1 markOne correct option

In xv6 operating system, trapframe struct holds the register context of a process when an interrupt occurs.

  1. A

    TRUE

  2. B

    FALSE

Show answer

Correct answer

  • A

    TRUE

Question 16

+1 markOne correct option

Match the following

  1. A

    1 - b, 2 - a, 3 - c

  2. B

    1 - c, 2 - b, 3 - a

  3. C

    1 - b, 2 - c, 3 - a

  4. D

    1 - c, 2 - a, 3 - b

Show answer

Correct answer

  • B

    1 - c, 2 - b, 3 - a

Question 17

+1 markNumerical answer
Show answer

Correct answer: 2

Question 18

+3 marksNumerical answer
Show answer

Correct answer: 5

Question 19

+3 marksNumerical answer

Consider the scenario given below in which the requests are serviced by C-SCAN disk scheduling algorithm.
Start: 12, tracks requested: [11, 0, 3, 4, 14, 8, 17, 9, 1].
Assume there are only 21 tracks in the disk numbered from 0 to 20.
What is the total number of head movements required to service all the requests using the C- SCAN algorithm?

Show answer

Correct answer: 18

Question 20

+2 marksNumerical answer
Show answer

Correct answer: 5

Question 21

+2 marksNumerical answer

For a scenario with 8 philosophers in the dining philosopher’s problem, what is the minimum number of forks necessary to ensure deadlock prevention?

Show answer

Correct answer: 9

Question 22

+4 marksOne or more correct options

Consider the following scenario where two processes are sharing a common variable which is modified in the critical section.

Global setup

c
int lock[2]= {0,0}, choice = 0;

Process 1

c
1 while(1){
2 lock[0] = 1;
3 choice = 1;
4 while(lock[1] && choice == 1);
5 // critical section
6 lock[0] = 0;
7 // remainder section
8 }

Process 2

c
1 while(1){
2 lock[1] = 1;
3 choice = 0;
4 while(lock[0] && choice == 0);
5 // critical section
6 lock[1] = 0;
7 // remainder section
8 }

Select the correct statements about the above processes.

Select all that apply.

  1. A

    It achieves mutual exclusion.

  2. B

    It can cause deadlock.

  3. C

    Process 2 can enter the critical section multiple times before a context switch if Process 1 is in remainder section.

  4. D

    Process 2 can enter the critical section multiple times before a context switch if Process 1 is waiting to enter the critical section.

Show answer

Correct answers

  • A

    It achieves mutual exclusion.

  • C

    Process 2 can enter the critical section multiple times before a context switch if Process 1 is in remainder section.

Question 23

+4 marksOne correct option

Consider the following code for allocproc.

c
1 static struct proc*
2 allocproc(void)
3 {
4 struct proc *p;
5
6 for(p = proc; p < &proc[NPROC]; p++) {
7 acquire(&p->lock);
8 if(p->state == UNUSED) {
9 goto found;
10 } else {
11 release(&p->lock);
12 }
13 }
14 return 0;
15
16 found:
17 p->pid = allocpid();
18 p->state = USED;
19
20 if((p->trapframe = (struct trapframe *)kalloc()) == 0){
21 freeproc(p);
22 release(&p->lock);
23 return 0;
24 }
25
26 p->pagetable = proc_pagetable(p);
27 if(p->pagetable == 0){
28 freeproc(p);
29 release(&p->lock);
30 return 0;
31 }
32
33 memset(&p->context, 0, sizeof(p->context));
34 p->context.ra = (uint64)forkret;
35 p->context.sp = p->kstack + PGSIZE;
36
37 return p;
38 }

Assuming no context switch occur during allocproc, which of the return statements in the above code gets executed if the freelist is empty when allocproc is called?

  1. A

    line 14

  2. B

    line 23

  3. C

    line 30

  4. D

    line 37

Show answer

Correct answer

  • B

    line 23

Question 24

+4 marksOne correct option

Consider the following functions that are used in the implementation of the Bakery algorithm:

c
1 lock(i) {
2 num[i] = MAX(num[0], num[1], ..., num[N-1]) + 1;
3 for (p = 0; p < N; ++p) {
4 while (num[p] != 0 && num[p] < num[i]);
5 }
6 }
7
8 unlock(i) {
9 num[i] = 0;
10 }

The function lock is called before entering the critical section and the unlock is called when the process comes out of the critical section. The value i will be the process number for each process.

Considering there are 4 processes, and initially num[0]=0, num[1]=2, num[2]=1, num[3]=4, select the order in which the above processes enter into the critical section

  1. A

    P0, P3, P1, P2

  2. B

    P0, P2, P1, P3

  3. C

    P2, P1, P3

  4. D

    P1, P3, P2

Show answer

Correct answer

  • C

    P2, P1, P3

Question 25

+4 marksOne correct option
  1. A

    (1) - C-SCAN, (2) - FCFS, (3) - SSTF, (4) - C-LOOK

  2. B

    (1) - C-LOOK, (2) - FCFS, (3) - C-SCAN, (4) - SSTF

  3. C

    (1) - C-SCAN, (2) - SSTF, (3) - FCFS, (4) - C-LOOK

  4. D

    (1) - C-SCAN, (2) - C-LOOK, (3) - SSTF, (4) - FCFS

Show answer

Correct answer

  • D

    (1) - C-SCAN, (2) - C-LOOK, (3) - SSTF, (4) - FCFS