Quiz Space

Operating Systems · Quiz 2 · 16 Mar 2025 · January 2025 term

Question 1: Consider the following scenario where two processes are s…

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 1 of 17 in the IIT Madras BS Operating Systems (Operating Systems) Quiz 2 paper sat on 16 Mar 2025, in the January 2025 term (IIT M IMPROVEMENT AN EXAM QIM2 16 Mar 2025). It carries 4 marks.

This question was also asked in

More questions from this paper

  1. Q2Assume that two processes P1 and P2 are using a shared resource. If P1 and P2 are both waiting indefinitely to enter th…
  2. Q3Figure question
  3. Q4Identify the correct system call that should be used at LINE-1 to execute the grep command in the following code:
  4. Q5What is the correct sequence of tasks that takes place during hardware interrupt handling? (i) Save the current CPU sta…
  5. Q6Which of the following is a disadvantage of the Shortest Job First (SJF) scheduling algorithm?
  6. Q7State True or False: In inter-process communication (IPC) using shared memory, the commonly used system calls are send …
  7. Q8Given the hexadecimal view of the first few bytes of different files, identify the executable file (ELF file) from the …
  8. Q9Figure question
  9. Q10Which scheduling algorithm is optimal in terms of minimizing the average waiting time?
  10. Q11What is the main drawback of a priority-based scheduling algorithm?
  11. Q12Assume that context switches can occur at any time during the execution of the following code snippet. The variable cou…
  12. Q13Choose all the correct statements regarding compiling and linking multiple C source files using gcc.
  13. Q14Consider the following code snippet from Bakery Algorithm. critical section Considering that there are 5 processes, and…
  14. Q15Figure question
  15. Q16Figure question
  16. Q17Figure question