uiz Space

January 2024 term · Operating Systems · BSCS4022

Operating Systems Quiz 2: 24 March 2024 (January 2024 term)

The IIT Madras BS Operating Systems (Operating Systems) Quiz 2 paper sat on 24 Mar 2024, in the January 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.

Questions
19
Marks
50
Duration
120 min
MCQ
15
Numerical
2
MSQ
2

Updated

Official paper: IIT M FOUNDATION AN EXAM QDF2 24 Mar 2024 · No negative marking.

Question 1

+2 marksOne correct option

Given the hexadecimal view of first few bytes of different files, identify the executable file (ELF file) from the options below. (Hint: The ASCII value of ’A’ = 65)

  1. A

    7f 41 51 45 02 01 01 00

  2. B

    6e 45 4c 46 02 01 01 00

  3. C

    7f 45 4c 46 02 01 01 00

  4. D

    7f 45 45 45 02 01 01 00

Show answer

Correct answer

  • C

    7f 45 4c 46 02 01 01 00

Question 2

+2 marksOne correct option
  1. A
  2. B
  3. C
  4. D
Show answer

Correct answer

  • D

Question 3

+2 marksOne correct option

Consider the code given below.

c
int pid;
pid = fork();
if (pid > 0){
pid = wait();
}else{
execlp("ls", "", NULL);
exit(0);
}

While the execlp("ls", "", NULL) function is running in the child process, what is the state of the parent process?

  1. A

    Sleeping

  2. B

    Running

  3. C

    Terminated

  4. D

    Waiting

Show answer

Correct answer

  • A

    Sleeping

Question 4

+2 marksOne correct option
  1. A

    Software events

  2. B

    Hardware events

  3. C

    Exceptions

  4. D

    All of these

Show answer

Correct answer

  • D

    All of these

Question 5

+2 marksOne correct option

Which of the following best describes the role of the Programmable Interrupt Controller (PIC) in the xv6 operating system?

  1. A

    It manages the allocation of memory resources to processes.

  2. B

    It coordinates the execution of system calls within the kernel.

  3. C

    It handles hardware interrupts from devices such as keyboards and timers.

  4. D

    It manages the scheduling of processes to ensure fairness and efficiency.

Show answer

Correct answer

  • C

    It handles hardware interrupts from devices such as keyboards and timers.

Question 6

+2 marksOne correct option

A situation where several processes access and manipulate the same data is referred to as ____________ .

  1. A

    static condition

  2. B

    race condition

  3. C

    critical section

  4. D

    dynamic condition

Show answer

Correct answer

  • B

    race condition

Question 7

+2 marksOne correct option

What system calls are commonly used for communication in message passing?

  1. A

    allocate and deallocate

  2. B

    send and receive

  3. C

    read and write

  4. D

    create and destroy

Show answer

Correct answer

  • B

    send and receive

Question 8

+3 marksOne correct option

Consider the partial help message from the readelf utility

bash
Usage: readelf <option(s)> elf-file(s)
Display information about the contents of ELF format files
Options are:
-h --file-header Display the ELF file header
-l --program-headers Display the program headers
-S --section-headers Display the sections' header

Match the following.

a) Linker view    1) readelf -l

b) Executable view    2) readelf -h

c) ELF header    3) readelf -S

  1. A

    a - 1, b - 2, c - 3

  2. B

    a - 1, b - 3, c - 2

  3. C

    a - 3, b - 1, c - 2

  4. D

    a - 3, b - 2, c - 1

Show answer

Correct answer

  • D

    a - 3, b - 2, c - 1

Question 9

+3 marksOne correct option

What is the correct sequence of tasks that takes place as part of hardware interrupt handling? (i) Process the interrupt
(ii) Restore CPU context and return
(iii) Invoke kernel scheduler
(iv) Save additional CPU context

  1. A

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

  2. B

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

  3. C

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

  4. D

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

Show answer

Correct answer

  • B

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

Question 10

+3 marksOne correct option
  1. A

    0x8000000000000001

  2. B

    0x8000000000000009

  3. C

    0x0000000000000001

  4. D

    0x0000000000000009

Show answer

Correct answer

  • B

    0x8000000000000009

Question 11

+3 marksOne correct option

Select the path traced in case of a timer interrupt caused while in the supervisor mode in xv6.

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

Correct answer

  • A

Question 12

+3 marksOne correct option
  1. A

    5.33

  2. B

    3.33

  3. C

    2.66

  4. D

    3

Show answer

Correct answer

  • B

    3.33

Question 13

+3 marksOne correct option
  1. A

    3

  2. B

    0.3

  3. C

    1

  4. D

    2

Show answer

Correct answer

  • A

    3

Question 14

+3 marksOne correct option

Assume that two processes P1 and P2 are sharing a variable. If P1 can go into critical section when the P2 is in the critical section, then which of the following conditions is not satisfied?

  1. A

    Mutual exclusion

  2. B

    Progress

  3. C

    Bounded waiting

  4. D

    None of these

Show answer

Correct answer

  • A

    Mutual exclusion

Question 15

+1 markOne correct option

Round Robin provides the same or a lower response time compared to First-Come-First-Serve (FCFS) scheduling algorithm.

  1. A

    TRUE

  2. B

    FALSE

Show answer

Correct answer

  • A

    TRUE

Question 16

+3 marksNumerical answer
Show answer

Correct answer: 4

Question 17

+3 marksNumerical answer

Consider the following code snippet from Bakery Algorithm.

c
lock(i) {
num[i] = MAX(num[0], num[1], ..., num[N-1]) + 1;
for (p = 0; p < N; ++p) {
while (num[p] != 0 && num[p] < num[i]);
}
}

critical section

c
unlock(i) {
num[i] = 0;
}

Considering there are 4 processes, and initially num[1]=0, num[2]=2, num[3]=1, num[4]=4, what will be the value of num[2] after running process 3 critical section?

Show answer

Correct answer: 2

Question 18

+4 marksOne or more correct options

Assuming context switches can occur at any time during the execution of the following code snippet, counter is a shared variable. Which of the following can be the possible final values of the counter variable?

python
# Program 0
counter = 5
R1 = counter
R1 = R1 + 2
counter = R1
# Program 1
R2 = counter
R2 = R2 - 2
counter = R2

Select all that apply.

  1. A

    4

  2. B

    6

  3. C

    5

  4. D

    3

  5. E

    7

  6. F

    8

Show answer

Correct answers

  • C

    5

  • D

    3

  • E

    7

Question 19

+4 marksOne or more correct options

Consider the following scenario where two processes are sharing a common variable.

Global setup

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

Process 1

c
while(1){
lock[0] = 1;
while(lock[1]);
// critical section
lock[0] = 0;
// remainder section
}

Process 2

c
while(1){
lock[1] = 1;
while(lock[0]);
// critical section
lock[1] = 0;
// remainder section
}

Select the correct statements about the above processes.

Select all that apply.

  1. A

    It achieves mutual exclusion.

  2. B

    It could 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.

  • B

    It could cause deadlock.

  • C

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