Quiz Space

Operating Systems · Quiz 2 · 4 Aug 2024 · May 2024 term

Question 15: Consider the following scenario where two processes are …

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 15 of 18 in the IIT Madras BS Operating Systems (Operating Systems) Quiz 2 paper sat on 4 Aug 2024, in the May 2024 term (IIT M IMPROVEMENT AN EXAM QIM4 4 Aug 2024). It carries 4 marks.

This question was also asked in

More questions from this paper

  1. Q1Figure question
  2. Q2Figure question
  3. Q3Figure question
  4. Q4Consider the following code snippet from Bakery Algorithm. critical section Considering there are 5 processes, and init…
  5. Q5In which scenario is the average response time for FCFS the same as for SJF?
  6. Q6Figure question
  7. Q7Identify the correct system call that should be used at LINE-1 to execute the ls command in the following code:
  8. Q8What is the correct sequence of tasks that takes place as part of software interrupt handling? (i) Execute the software…
  9. Q9State True or False\ SJF scheduling can lead to starvation of longer jobs if shorter jobs keep arriving.
  10. Q10State True or False\ SJF can provide a better average response time than FCFS for a set of jobs with varying lengths.
  11. Q11Figure question
  12. Q12Which of the following are scheduling criteria in an operating system?
  13. Q13Figure question
  14. Q14Assuming context switches can occur at any time during the execution of the following code snippet, balance is a shared…
  15. Q16Assume that two processes P3 and P4 are sharing a resource. If P3 is never able to enter its critical section because P…
  16. Q17Given the hexadecimal view of the first few bytes of different files, identify the executable file (ELF file) from the …
  17. Q18Figure question