Quiz Space

Operating Systems · Quiz 2 · 24 Mar 2024 · January 2024 term

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

Question 19

+4 marksOne or more correct options

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

Global setup

c
int lock[2]= {0,0};

Process 1

c
while(1){
lock[0] = 1;
while(lock[1]);
// critical section
lock[0] = 0;
// remainder section
}

Process 2

c
while(1){
lock[1] = 1;
while(lock[0]);
// critical section
lock[1] = 0;
// remainder section
}

Select the correct statements about the above processes.

Select all that apply.

  1. A

    It achieves mutual exclusion.

  2. B

    It could cause deadlock.

  3. C

    Process 2 can enter the critical section multiple times before a context switch if Process 1 is in remainder section.

  4. D

    Process 2 can enter the critical section multiple times before a context switch if Process 1 is waiting to enter the critical section.

Show answer

Correct answers

  • A

    It achieves mutual exclusion.

  • B

    It could cause deadlock.

  • C

    Process 2 can enter the critical section multiple times before a context switch if Process 1 is in remainder section.

Question 19 of 19 in the IIT Madras BS Operating Systems (Operating Systems) Quiz 2 paper sat on 24 Mar 2024, in the January 2024 term (IIT M FOUNDATION AN EXAM QDF2 24 Mar 2024). It carries 4 marks.

More questions from this paper

  1. Q1Given the hexadecimal view of first few bytes of different files, identify the executable file (ELF file) from the opti…
  2. Q2Figure question
  3. Q3Consider the code given below. While the execlp("ls", "", NULL) function is running in the child process, what is the s…
  4. Q4Figure question
  5. Q5Which of the following best describes the role of the Programmable Interrupt Controller (PIC) in the xv6 operating syst…
  6. Q6A situation where several processes access and manipulate the same data is referred to as .
  7. Q7What system calls are commonly used for communication in message passing?
  8. Q8Consider the partial help message from the readelf utility Match the following. a) Linker view    1) readelf …
  9. Q9What is the correct sequence of tasks that takes place as part of hardware interrupt handling? (i) Process the interrup…
  10. Q10Figure question
  11. Q11Select the path traced in case of a timer interrupt caused while in the supervisor mode in xv6.
  12. Q12Figure question
  13. Q13Figure question
  14. Q14Assume that two processes P1 and P2 are sharing a variable. If P1 can go into critical section when the P2 is in the cr…
  15. Q15Round Robin provides the same or a lower response time compared to First-Come-First-Serve (FCFS) scheduling algorithm.
  16. Q16Figure question
  17. Q17Consider the following code snippet from Bakery Algorithm. critical section Considering there are 4 processes, and init…
  18. Q18Assuming context switches can occur at any time during the execution of the following code snippet, counter is a shared…