uiz Space

May 2024 term · Operating Systems · BSCS4022

Operating Systems Quiz 2: 4 August 2024 (May 2024 term)

The IIT Madras BS Operating Systems (Operating Systems) Quiz 2 paper sat on 4 Aug 2024, in the May 2024 term: 18 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
18
Marks
50
Duration
120 min
Numerical
4
MCQ
11
MSQ
3

Updated

Official paper: IIT M IMPROVEMENT AN EXAM QIM4 4 Aug 2024 · No negative marking.

Question 1

+4 marksNumerical answer
Show answer

Correct answer: 6

Question 2

+4 marksNumerical answer
Show answer

Correct answer: 4

Question 3

+4 marksNumerical answer
Show answer

Correct answer: 1

Question 4

+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 there are 5 processes, and initially num[0]=5 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 5

+2 marksOne correct option

In which scenario is the average response time for FCFS the same as for SJF?

  1. A

    When all jobs have the same length

  2. B

    When jobs arrive in increasing order of length

  3. C

    When jobs arrive in decreasing order of length

  4. D

    When jobs have widely varying lengths

Show answer

Correct answer

  • A

    When all jobs have the same length

Question 6

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

Correct answer

  • C

Question 7

+2 marksOne correct option

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

c
int pid;
pid = fork();
if(pid > 0){
pid = wait();
}
______("ls", "", NULL); //LINE-1
exit(0);
  1. A
  2. B
  3. C
  4. D
Show answer

Correct answer

  • C

Question 8

+2 marksOne correct option

What is the correct sequence of tasks that takes place as part of software interrupt handling? (i) Execute the software interrupt handler
(ii) Save the current CPU state
(iii) Invoke the kernel scheduler if needed
(iv) Restore the CPU state and resume execution

  1. A

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

  2. B

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

  3. C

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

  4. D

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

Show answer

Correct answer

  • D

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

Question 9

+1 markOne correct option

State True or False
SJF scheduling can lead to starvation of longer jobs if shorter jobs keep arriving.

  1. A

    TRUE

  2. B

    FALSE

Show answer

Correct answer

  • A

    TRUE

Question 10

+1 markOne correct option

State True or False
SJF can provide a better average response time than FCFS for a set of jobs with varying lengths.

  1. A

    TRUE

  2. B

    FALSE

Show answer

Correct answer

  • A

    TRUE

Question 11

+1 markOne correct option
  1. A

    TRUE

  2. B

    FALSE

Show answer

Correct answer

  • B

    FALSE

Question 12

+3 marksOne or more correct options

Which of the following are scheduling criteria in an operating system?

Select all that apply.

  1. A

    Maximize CPU utilization

  2. B

    Maximize thoughput

  3. C

    Maximize response time

  4. D

    Minimize response time

  5. E

    Minimize waiting time

  6. F

    Minimize CPU utilization

  7. G

    Maximize waiting time

Show answer

Correct answers

  • A

    Maximize CPU utilization

  • B

    Maximize thoughput

  • D

    Minimize response time

  • E

    Minimize waiting time

Question 13

+3 marksOne or more correct options

Select all that apply.

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

Correct answers

  • B
  • D

Question 14

+4 marksOne or more correct options

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

python
# Program 0
balance = 50
R1 = balance
R1 = R1 + 20
balance = R1
# Program 1
R2 = balance
R2 = R2 - 20
balance = R2

Select all that apply.

  1. A

    40

  2. B

    60

  3. C

    50

  4. D

    30

  5. E

    70

  6. F

    80

Show answer

Correct answers

  • C

    50

  • D

    30

  • E

    70

Question 15

+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 16

+3 marksOne correct option

Assume that two processes P3 and P4 are sharing a resource. If P3 is never able to enter its critical section because P4 keeps entering its critical section repeatedly, 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

  • C

    Bounded waiting

Question 17

+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 50 51 52 02 01 01 00

  2. B

    7f 45 4d 50 02 01 01 00

  3. C

    7f 41 42 43 02 01 01 00

  4. D

    7f 45 4c 46 02 01 01 00

Show answer

Correct answer

  • D

    7f 45 4c 46 02 01 01 00

Question 18

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

Correct answer

  • B