
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.
- 18
- 50
- 120 min
- 4
- 11
- 3
Show answer
Correct answer: 6
Question 2
Show answer
Correct answer: 4
Question 3
Show answer
Correct answer: 1
Question 4
Consider the following code snippet from Bakery Algorithm.
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
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
In which scenario is the average response time for FCFS the same as for SJF?
When all jobs have the same length
When jobs arrive in increasing order of length
When jobs arrive in decreasing order of length
When jobs have widely varying lengths
Show answer
Correct answer
When all jobs have the same length
Question 6
Show answer
Correct answer
Question 7
Identify the correct system call that should be used at LINE-1 to execute the ls command in the following code:
int pid;pid = fork();if(pid > 0){ pid = wait();}______("ls", "", NULL); //LINE-1exit(0);Show answer
Correct answer
Question 8
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
(i) → (ii) → (iii) → (iv)
(iii) → (i) → (ii) → (iv)
(ii) → (iii) → (i) → (iv)
(ii) → (i) → (iii) → (iv)
Show answer
Correct answer
(ii) → (i) → (iii) → (iv)
Question 9
State True or False
SJF scheduling can lead to starvation of longer jobs if shorter jobs keep arriving.
TRUE
FALSE
Show answer
Correct answer
TRUE
Question 10
State True or False
SJF can provide a better average response time than FCFS for a set of jobs with varying lengths.
TRUE
FALSE
Show answer
Correct answer
TRUE
Question 11
TRUE
FALSE
Show answer
Correct answer
FALSE
Question 12
Which of the following are scheduling criteria in an operating system?
Maximize CPU utilization
Maximize thoughput
Maximize response time
Minimize response time
Minimize waiting time
Minimize CPU utilization
Maximize waiting time
Show answer
Correct answers
Maximize CPU utilization
Maximize thoughput
Minimize response time
Minimize waiting time
Question 13
Show answer
Correct answers
Question 14
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?
# Program 0balance = 50R1 = balanceR1 = R1 + 20balance = R1
# Program 1R2 = balanceR2 = R2 - 20balance = R240
60
50
30
70
80
Show answer
Correct answers
50
30
70
Question 15
Consider the following scenario where two processes are sharing a common variable.
Global setup
int turn = 1;Process 1
while(1) { while(turn == 2); // lock // critical section turn = 2; // unlock // remainder section}Process 2
while(1) { while(turn == 1); // lock // critical section turn = 1; // unlock // remainder section}Which of the following statements about the given processes is correct?
Process 1 and Process 2 will enter their critical sections simultaneously, leading to race conditions.
Process 1 will always enter its critical section before Process 2.
Process 2 will always enter its critical section before Process 1.
Deadlock can occur if both processes try to enter their critical sections simultaneously.
Show answer
Correct answer
Process 1 will always enter its critical section before Process 2.
Question 16
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?
Mutual exclusion
Progress
Bounded waiting
None of these
Show answer
Correct answer
Bounded waiting
Question 17
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)
7f 50 51 52 02 01 01 00
7f 45 4d 50 02 01 01 00
7f 41 42 43 02 01 01 00
7f 45 4c 46 02 01 01 00
Show answer
Correct answer
7f 45 4c 46 02 01 01 00
Question 18
Show answer
Correct answer