uiz Space

January 2025 term · Operating Systems · BSCS4022

Operating Systems Quiz 2: 16 March 2025 (January 2025 term)

The IIT Madras BS Operating Systems (Operating Systems) Quiz 2 paper sat on 16 Mar 2025, in the January 2025 term: 17 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
17
Marks
50
Duration
120 min
MCQ
11
MSQ
2
Numerical
4

Updated

Official paper: IIT M IMPROVEMENT AN EXAM QIM2 16 Mar 2025 · No negative marking.

Question 1

+4 marksOne correct option

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

Global setup

c
int turn = 1;

Process 1

c
while(1) {
while(turn == 2); // lock
// critical section
turn = 2; // unlock
// remainder section
}

Process 2

c
while(1) {
while(turn == 1); // lock
// critical section
turn = 1; // unlock
// remainder section
}

Which of the following statements about the given processes is correct?

  1. A

    Process 1 and Process 2 will enter their critical sections simultaneously, leading to race conditions.

  2. B

    Process 1 will always enter its critical section before Process 2.

  3. C

    Process 2 will always enter its critical section before Process 1.

  4. D

    Deadlock can occur if both processes try to enter their critical sections simultaneously.

Show answer

Correct answer

  • B

    Process 1 will always enter its critical section before Process 2.

Question 2

+2 marksOne correct option

Assume that two processes P1 and P2 are using a shared resource. If P1 and P2 are both waiting indefinitely to enter their critical sections because each keeps waiting for the other to release the resource, 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

  • B

    Progress

Question 3

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

Correct answer

  • C

Question 4

+2 marksOne correct option

Identify the correct system call that should be used at LINE-1 to execute the grep command in the following code:

c
int pid;
pid = fork();
if (pid > 0) {
wait(NULL);
}
______("grep", "pattern", "file.txt", NULL); // LINE-1
exit(0);
  1. A

    execl

  2. B

    execvp

  3. C

    execlp

  4. D

    exec

Show answer

Correct answer

  • C

    execlp

Question 5

+2 marksOne correct option

What is the correct sequence of tasks that takes place during hardware interrupt handling? (i) Save the current CPU state
(ii) Identify the interrupt source
(iii) Execute the interrupt service routine (ISR)
(iv) Invoke the kernel scheduler if needed
(v) Restore the CPU state and resume execution

  1. A

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

  2. B

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

  3. C

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

  4. D

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

Show answer

Correct answer

  • D

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

Question 6

+2 marksOne correct option

Which of the following is a disadvantage of the Shortest Job First (SJF) scheduling algorithm?

  1. A

    It always leads to the highest average waiting time

  2. B

    It does not consider burst time while scheduling

  3. C

    It can cause starvation for longer processes

  4. D

    It executes processes in a strictly Round-Robin manner

Show answer

Correct answer

  • C

    It can cause starvation for longer processes

Question 7

+1 markOne correct option

State True or False: In inter-process communication (IPC) using shared memory, the commonly used system calls are send and receive.

  1. A

    True

  2. B

    False

Show answer

Correct answer

  • B

    False

Question 8

+3 marksOne correct option

Given the hexadecimal view of the first few bytes of different files, identify the executable file (ELF file) from the options below. (Hint: The ASCII value of ’E’ = 69, ’L’ = 76, and ’F’ = 70)

  1. A

    7F 42 43 44 02 01 01 00

  2. B

    7F 45 4D 50 02 01 01 00

  3. C

    7F 45 4C 46 02 01 01 00

  4. D

    7F 50 51 52 02 01 01 00

Show answer

Correct answer

  • C

    7F 45 4C 46 02 01 01 00

Question 9

+3 marksOne correct option
  1. A

    0x800000000000000F

  2. B

    0x000000000000000D

  3. C

    0x000000000000000F

  4. D

    0x8000000000000005

Show answer

Correct answer

  • C

    0x000000000000000F

Question 10

+3 marksOne correct option

Which scheduling algorithm is optimal in terms of minimizing the average waiting time?

  1. A

    First-Come, First-Served (FCFS)

  2. B

    Shortest Job First (SJF)

  3. C

    Round Robin (RR)

  4. D

    Priority Scheduling

Show answer

Correct answer

  • B

    Shortest Job First (SJF)

Question 11

+3 marksOne correct option

What is the main drawback of a priority-based scheduling algorithm?

  1. A

    High complexity

  2. B

    Inefficiency in CPU utilization

  3. C

    Average waiting is more for higher priority process

  4. D

    Starvation of low-priority processes

Show answer

Correct answer

  • D

    Starvation of low-priority processes

Question 12

+4 marksOne or more correct options

Assume that context switches can occur at any time during the execution of the following code snippet. The variable counter is shared between two programs. Which of the following can be the possible final values of counter?

Initial value of counter =100=100

python
# Program A
R1 = counter
R1 = R1 + 10
counter = R1
# Program B
R2 = counter
R2 = R2 - 30
counter = R2

Select all that apply.

  1. A

    70

  2. B

    80

  3. C

    90

  4. D

    100

  5. E

    110

  6. F

    120

Show answer

Correct answers

  • A

    70

  • B

    80

  • E

    110

Question 13

+3 marksOne or more correct options

Choose all the correct statements regarding compiling and linking multiple C source files using gcc.

Select all that apply.

  1. A

    The command gcc file1.c file2.c -o output produces an executable named output.

  2. B

    The command gcc -c file1.c file2.c -o output produces an executable named output.

  3. C

    The command gcc -c file1.c file2.c produces file1.o and file2.o.

  4. D

    The command gcc file1.o file2.o -c -o output produces an executable named output.

  5. E

    The command gcc file1.o file2.o -o output links the object files into an executable named output.

Show answer

Correct answers

  • A

    The command gcc file1.c file2.c -o output produces an executable named output.

  • C

    The command gcc -c file1.c file2.c produces file1.o and file2.o.

  • E

    The command gcc file1.o file2.o -o output links the object files into an executable named output.

Question 14

+4 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 that there are 5 processes, and initially num[0]=3 num[1]=0, num[2]=5, num[3]=2, num[4]=4, If Process 4 (num[3]) starts executing its critical section and then unlocks, what will be the new value of num[3] after P4 finishes execution?

Show answer

Correct answer: 0

Question 15

+4 marksNumerical answer
Show answer

Correct answer: 8

Question 16

+4 marksNumerical answer
Show answer

Correct answer: 8.5

Question 17

+4 marksNumerical answer
Show answer

Correct answer: 1.75