🔒 CS330: Operating Systems

Chapter 6: Process Synchronization - Comprehensive Exam

⏱️ Duration: 90 minutes
📊 Total Marks: 50
📝 Questions: 14
Section 1: Multiple Choice Questions (20 Marks)
Question 1 Past Exam 2 Marks
What is the primary purpose of Peterson's solution in the context of process synchronization?
Question 2 Past Exam 2 Marks
How are counting semaphores utilized to control resource access?
Question 3 Past Exam 2 Marks
How can we prevent deadlock in the Dining Philosophers problem using semaphores?
Question 4 Past Exam 2 Marks
How can race conditions be mitigated in an operating system?
Question 5 Past Exam 2 Marks
What is a semaphore in operating systems?
Question 6 Past Exam 2 Marks
Which condition must be met for deadlock to occur?
Question 7 Past Exam 2 Marks
What does a semaphore initialized to 1 typically represent?
Question 8 Past Exam 2 Marks
What is mutual exclusion?
Question 9 Past Exam 2 Marks
Which is NOT a condition necessary for deadlock?
Question 10 Past Exam 2 Marks
In the context of process synchronization, what is busy waiting?
Section 2: Short Answer Questions (18 Marks)
Question 11 Past Exam 4 Marks
What does it mean for a solution to the critical section problem to satisfy the condition of mutual exclusion for two processes P1 and P2? Also, explain why disabling interrupts cannot be a general solution to the critical section problem (give two reasons).
Question 12 Past Exam 5 Marks
What is the producer-consumer problem? Describe how semaphores can be used to solve this problem. Include the semaphores needed and their initial values.
Question 13 5 Marks
Explain the three requirements that any solution to the critical section problem must satisfy: Mutual Exclusion, Progress, and Bounded Waiting.
Question 14 4 Marks
What is a monitor in concurrent programming? How does it differ from semaphores in terms of ease of use and error prevention?
Section 3: Code Analysis (12 Marks)
Question 15 Past Exam 12 Marks

Consider two processes P1 and P2 executing concurrently and sharing a semaphore S, which is initialized to 0. The semaphore operations in the processes appear as shown below:

Process P1 Process P2 - - - - S1 S2 wait(S) signal(S) - - - -

a) Which one of the following is true? (4 marks)

  • (i) S1 and S2 will execute in any order
  • (ii) S1 will always execute before S2
  • (iii) S1 will always execute after S2
  • (iv) P1 and P2 will be deadlocked

b) Explain your answer with reasoning. (4 marks)

c) What would happen if S was initialized to 1 instead of 0? (4 marks)